- Home /
Terrain detail meshes/trees via script?
How do I access the terrain detail section in the terrain data so I can paint it on the ground via script.
I have a script that procedurally generates the terrain by doing a few passes on perlin noise etc etc... and also adding textures, but have no idea how to do the same with terrain objects like trees and rocks in the same way it is painted manually.
I can instantiate them as game objects on the terrain randomly but that takes a lot of power and they don't have the nice culling stuff the terrain detail meshes do.
I'm sure this has been asked before, but I am having a tough time finding out how to do it.
Thanks.
@Dead$$anonymous$$enny Could you please share your solution for this?
Answer by jeffreymarkbaldridge · Dec 23, 2014 at 05:12 PM
http://docs.unity3d.com/ScriptReference/TerrainData-treeInstances.html
I believe this is the array that holds the data for the different instances of the trees.
Hmmm, not exactly what I am looking for but it helps somewhat. Thanks.
Wait does it get the trees placed on the terrain or added to the script?
If its the former then its exactly what I need. Busy looking now... I will accept answer if its true.
Ok it isn't working as I intended. Too complicated, I'm going to try place them a different way.
From my understanding of other features in Unity, this would provide a copy of the array of trees currently placed on the TerrainData you are calling this from. $$anonymous$$ost likely you would need to provide it an array with your generated trees to change it.
I found another way. $$anonymous$$ade a separate script that instantiates trees/rocks into the scene with LOD and parents them.
Answer by Favor_89 · May 23, 2017 at 08:46 AM
@DeadKenny Could you please share your solution for this?