Hi, I need to procedurally generate my terrains. In my case, depending on where the user clicks on a world map, different splat maps should be applied to the local terrain. How does one do this ?
This code :
TerrainData t = gameObject.GetComponent<Terrain>().terrainData;
t.splatPrototypes[0].texture = exampleTex;
t.RefreshPrototypes();
…does exactly nothing.
So after some time to think, I got the idea to just change the Terrain material instead. However, since TerrainRenderer is an internal-sealed non Monobehaviour(eg it does not inherit from MeshRenderer and therefore cannot be gotten via .renderer) I can’t see a way to get its’ Material. Terrain.materialTemplate returns null, so that’s not it either.
Any help would be appreciated on this. I’d go great lengths to finally be able to set my splatmaps via code.
[This is a duplicate post of Get Terrain material / Set splat maps - Questions & Answers - Unity Discussions ]