Jump to content

GeNa Road Spline - Bake


Lenar
 Share

Go to solution Solved by Peter,

Recommended Posts

Hi, in my scene I have about 4 road splines, after I make changes to splines and call some function (editor only) I need:

1. Alpine Meadow Biome Texture and Grass to be recomputed ("Spawn World" button effect)

2. Call Road Spline Texture extension ("Texture" button effect)

3. Call Road Spline Road extension ("Bake" button effect)

 

How can I get access to Road Splines extensions and biomes via script?

Link to comment
Share on other sites

As far as accessing the GeNa Extentions on a spline the following code is an example:
            GeNaRoadExtension road = spline.GetExtension<GeNaRoadExtension>();
If the spline contains a GeNaRoadExtension then road variable will contain a reference to it, otherwise it will be null.

The same type of code can be used to access any GeNa Extension from a spline.

Link to comment
Share on other sites

   Thanks! After modify roads, I press button in inspector to call this method:

1. I call Carve on all roads (works fine)

2. Spawn Textures and Grass (works fine)

3. Bake road (road is baked), but texture extension shoulder effect not applied. Once I move this step to other button it works fine.

I tried add delay but not works, I just want this to be executed by pressing one single button.

 public List<Spline> mapSplines = new List<Spline>();
    public List<Gaia.Spawner> mapSpawners = new List<Gaia.Spawner>();

// Sirenix.OdinInspector Buttton attribute   
[Button]
    void Bake()
    {
        // Road splines carves only
        foreach (Spline spline in mapSplines)
        {
            GeNaCarveExtension carve = spline.GetExtension<GeNaCarveExtension>();
            carve.Carve();
        }

        // Texture and grass spawners
        foreach (Gaia.Spawner spawner in mapSpawners)
        {
            spawner.Spawn(true);
        }
        // If I call this part on other button event result is normal
        // Road spline bake
        foreach (Spline spline in mapSplines)
        {
            spline.Bake();
        }
    }

 

Link to comment
Share on other sites

@Lenar, I think what you are seeing is the result of the Gaia spawners overwriting the Spline texturing, since the Gaia Spawners actually execute as a coroutine.  The call to the Gaia Spawner to Spawn initializes a coroutine for the spawner, which will execute once control is returned to Unity.

Perhaps you, I, or someone else, can find an elegant solution for this.

 

  • Like 1
Link to comment
Share on other sites

  • Solution

@Lenar I can confirm that what Clyde suggested above is correct, the Gaia spawner runs in a coroutine for various technical reasons - this means the spawning starts, but the code in your own script continues before the spawner is finished, leading to the situation that the GeNa spline texturing happens before the Gaia texture spawn, so Gaia immediately after overwrites the textures again.
What you could do to prevent this is to check in your script until the field "m_updateCoroutine" on each spawner is null, then the coroutine(s) should be finished.
The coroutines in the unity editor are based on the IENumerator interface. Alternatively you could push the coroutine execution forward by calling the "MoveNext" function from the IEnumerator yourself, but this might lead to issues in larger world spawns as unity does not regain control to clean up memory while the spawn is running.

Link to comment
Share on other sites

7 hours ago, Clyde said:

@Lenar, I think what you are seeing is the result of the Gaia spawners overwriting the Spline texturing, since the Gaia Spawners actually execute as a coroutine.  The call to the Gaia Spawner to Spawn initializes a coroutine for the spawner, which will execute once control is returned to Unity.

Perhaps you, I, or someone else, can find an elegant solution for this.

 

This explains a lot, I'll try to find a solution

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Tell a friend

    Love Unity 3D World & Game Creation Tools - Canopy - Procedural Worlds? Tell a friend!
  • Interesting Articles

    1. 2

      I'm getting tired of doing islands and craters

    2. 2

      I'm getting tired of doing islands and craters

    3. 1

      Problems with latest Gaia Update

    4. 1

      Adding shoreline or waterline effects, beaches, river banks, etc.

    5. 1

      Just upgraded my Canopy to Pro

×
×
  • Create New...