- Home /
Question by
Pyrodus · Mar 16, 2017 at 09:12 AM ·
c#terrainterraindataterraintexture
C#: Changing Terrain Textures
Hello!
I am looking to change a terrain texture and texture size in runtime.
As shown above, I have a terrain object and a texture. I am trying to change the texture albedo and size during runtime.
I think I am on the right track, through trying to edit the splatPrototype. Is this the approach I should use? Below is my current code -- it compiles without error, however fails to change the texture...
public Material PlanetBiomeMap; // assigned to valid material
Texture2D TerrainMap = (Texture2D)PlanetBiomeMap.mainTexture; // extracts texture from biome map
Terrain PlanetTerrain = transform.Find ("Terrain").GetComponent<Terrain>(); // finds terrain
TerrainData PlanetTerrainData = PlanetTerrain.terrainData; // terrain's data object
PlanetTerrainData.splatPrototypes[0].texture = TerrainMap; // *I think?* changes first texture
All help is appreciated!
unityissue.jpg
(177.9 kB)
Comment