- Home /
The question is answered, right answer was accepted
How to clear TreeInstance-list?
So I'm trying to do procedural generation with the terrain in Unity. I do this by setting the heightmap and detailmap from noise-functions. It works fine. I've now started to put out trees, but what I notice is that the trees are saved in the Treeinstances array after each session, and then duplicated when I start the game (in the editor) again.
Is there a way to clear the terrainData.Treeinstances list? The ".Clear()" method in System.collections.generic doesn't work. So how would I go about to remove all elements? (So that I can then put in new ones in run-time)
Answer by cjdev · Aug 26, 2015 at 08:23 PM
TerrainData.treeInstances is actually an array not a list. Try doing
using System;
Array.Clear(yourArray, 0, yourArray.Length);
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Procedural generated mesh problem 1 Answer
Filling area under linerenderer 2 Answers
How to get the GameObject reference with using trees in script? 0 Answers