I can't figure out how these work, here is the code I have.
var instances = new ArrayList();
if (index >= 0) {
var instance = new TreeInstance();
instance.position = new Vector3(ChunkPosX + x, height, ChunkPosZ + z);
instance.color = Color.white;
instance.lightmapColor = Color.white;
instance.prototypeIndex = index;
instances.Add(instance);
}
Terrain.activeTerrain.terrainData.treeInstances = instances.ToArray(typeof(TreeInstance));
The problem is that the trees doesn't show in game. I have checked that the prototypes are working and they are working just fine.
NOTE: Index gets assigned by another part of the code, and its between the in game prototypes.
↧