- Home /
Question by
mprivat · Mar 30, 2015 at 09:18 AM ·
terrainterraindataterraintexture
Alphamaps with new cloned terrain
I am tiling terrains together. It works well for the height maps, all my tiles are properly showing their own relief. Where things go weird is when setting the alpha maps of the new tiles.
I am making sure to clone the TerrainData from my template tile
TerrainData data = UnityEngine.Object.Instantiate(template.terrainData) as TerrainData;
GameObject terrainObject = Terrain.CreateTerrainGameObject(data);
Terrain result = terrainObject.GetComponent<Terrain>();
If I set the alpha maps on result
, it sets it for all the terrains in my scene, including the template. So obviously something isn't cloned corectly, but I have no idea where.
To set the alpha map, all I do is:
float[,,] map = new float[result.terrainData.alphamapWidth,
result.terrainData.alphamapHeight,
result.terrainData.alphamapLayers];
then after filling the map values:
result.terrainData.SetAlphamaps(0, 0, map);
I have no idea what I'm doing wrong
Comment
Your answer
Follow this Question
Related Questions
SetAlphaMaps Opacity Gradient 0 Answers
SetPixel() on Terrain 0 Answers
Sample Color on Terrain 0 Answers
Get Terrain textures 1 Answer