Hi,
I’m adding trees to my terrain from code (at random positions), and they show up, though they are completely black…
When I place the same tree-prefab from the editor, they do have color…
In code I first create the terrainData and then create the terrain using Terrain.CreateTerrainGameObject(terrData);
. Also tried first adding the treePrototypes to the terrainData, then creating the terrain, and then adding the trees directly to the terrain. I also flush the terrain after this (just to be sure, didn’t seem to help anything.)
Someone asked to clarify:
What I do is I create a terrainData, to this terrainData’s treePrototypes I add all the tree-prefabs (and set their bendfactor), then I place a few trees on the terrain at a random position by adding TreeInstances to terrainData.treeInstances. This gives my a terrain, with a bunch of black trees… (This all happens when the game is running.)
Then when I go to the scene view, select the created terrain, and then add TreeInstances using the painting-thing, I get properly coloured trees!
Though while writing this, I realize that I probably just forgot to set the color value in the TreeInstance when making them in code. I will check this when I get home (end of the week.)
Anyone any idea why this is?