I’m currently changing the colour of trees placed by the terrain tool, however iterating through treeInstances causes the client to freeze for a few seconds due to the size of it (several thousand trees). Any suggestions on how I could speed up this process? for(var treenum : int = 0; treenum < terrainData.treeInstances.Length; treenum++)
AFAIK There’s no magic fix for this, iterating through terrain treeInstances is going to incur that (less trees help of course).
I work on a project where we have a large terrain with > 1 million trees and apparently there is a magic behind this. As weird as it seems, using terrainData.treeInstances.Length
in the loop is a source of performance issues, even if you have a very simple operation inside. The solution is to use terrainData.treeInstanceCount
instead! Solved for me.