Hey guys,
I need to get one tree out of the treeInstances array, since there is only AddTreeInstance but no function to remove, I wrote it like this.
It works fine, with 5000 trees I just have a little lag everytime a tree gets deleted.
Creating a whole new array everytime is ineffective but the array size is static, so I see no better way.
Do You know a better/faster way to do this?
List<TreeInstance> tempTreeInstance = new List<TreeInstance>();
tempTreeInstance.AddRange(Terrain.activeTerrain.terrainData.treeInstances);
tempTreeInstance.RemoveAt(id);
trees.RemoveAt(id); //array of interactive invisible trees at terrain tree locations
Terrain.activeTerrain.terrainData.treeInstances = tempTreeInstance.ToArray();
Thanks in advance!