splatPrototype.texture broken?

Hi all.

So lately ive been playing with the terraindata.splatPrototype variable. It contains the texture from what I can tell that i am using to create my terrain. So if I got grass,sand,dirt.

terraindata.splatPrototype[0].texture.name == "grass"

and this is allowed/true, I check the splatPrototype’s name after wards and it checks out.

So my problem is when I try something like

terraindata.splatPrototype[0].texture = grassTxt;

IT compiles and runs, no errors, but it never changes the texture.

Any idea why I can assign these variables, but they still do nothing? Is this a built in problem or am I just going crazy. Any idea how to get around this.

I’ve run into a similar problem, even after using the Flush() method to (allegedly) apply the changes.
Why is there virtually no documentation for anything dealing with runtime modification of terrain?

Same problem here, I’m trying to change the textures on the terrain through a custom editor script with something like this :

terrain.terraindata.splatPrototype[0].texture = MyTexture;

If I then output a Debug.Log, my splatPrototype still has the same value even though the function above does not report an error.

Any idea on how to make this work anyone ?

EDIT: I actually found a workaround by modifying the content of the textures while keeping the same file name instead of jumping from a texture to another, seems to work…

Terrains and GUI are two of Unity’s serious failings. I’ve just come across this problem myself. This order worked for me:

  • Create TerrainData (set all properties – detail resolution, size, etc)
  • terrainData.SetHeights()
  • Add TerrainCollider and have it use terrainData
  • Create an array of SplatPrototypes and fill it with texture references
  • terrainData.splatPrototypes = array created in the previous step
  • terrainData.SetAlphaMaps

And yeah, once the splat map prototypes are set, nothing can alter the textures that they use except Unity’s terrain inspector.