- Home /
Access terrain alphamaps directly? To clone them?
How do you clone a terrain's alphamap? It's inaccessible according to unity intellisense?
In case anyone reading this doesn't understand: setalphamaps() changes all clones of the terrain. Not just the terrain you use it on.
The Solution: Clone the alpha map.
The Problem: Can't access the alpha map's Texture2D object.
Hence this question being here.
Answer by Eric5h5 · Nov 30, 2014 at 05:05 PM
TerrainData.GetAlphamaps
SetAlphamaps will only be applied to the terrain you use it on, as long as the terrain is an instance.
Took my problem and called it an answer. This question is still unanswered and if anyone knows how to clone the alpha maps, please let me know, thanks.
No, this is the answer. You apparently didn't understand it. You clone alpha maps by using GetAlphamaps and SetAlphamaps. There is no other way. If you've made your terrains unique then it works.
Eric, my terrains have the word (clone) after them in the hierarchy. Their colliders also have the word (clone) where "terraindata" is. And a setalphamap() on any one of the clones still changes them all. If my terrains are not "unique" then how do I make them more unique than this? Have you actually tested your code or are you just saying this? I kind of still don't think you are right but I'd be happy to be proven wrong.
Yes, it works fine; I've used it before and that's why I posted this answer. Just because the terrain object is a clone doesn't mean the terraindata it's using is a unique instance. Just like you can have many different objects using the same texture. If you use SetPixel on the texture, all the objects will change. If you don't want that, then you make unique textures. Same with terraindata.
Answer by b1gry4n · Nov 30, 2014 at 05:31 PM
You need to apply a new terrain data to the terrain(s) you want unique. modifying terraindata directly without "cloning" will update all terrain using that terrain data.
TerrainData newTerrainData = (TerrainData) Object.Instantiate(terData);
doing this in combination with erics answer will provide a solution
http://answers.unity3d.com/questions/211544/making-duplicate-terrain-unique.html
I appreciate your attempt to answer. However, I did clone the terraindata separately already. Alphamaps don't get cloned with the terraindata. Question still unanswered, anyone else know?
@AaronBrownL$$anonymous$$? are you found solution? How are you clone?
Now I see only one solution: create several TerrainData dublicates.
Your answer
Follow this Question
Related Questions
Update terrain alphamap at runtime makes my game crawling 3 Answers
Strange Error With AlphaMapHeight 0 Answers
Terrain edge fading into alpha mask 0 Answers
how does a splatmap alpha maps work (terrains) etc... 1 Answer
Instatiating an object. Altering that new object causes prefab to be altered. 2 Answers