- Home /
Updating detailPrototypes...
I am writing code to update the grass detail prototypes assigned to the active terrain. That is, my code is looping through each grass detail prototype and trying to set all it's properties (e.g. grass colors, sizes, etc.) to be the same as all the others grass prototypes vs. having to hand edit each grass manually one by one.
I am am able to access all the grass prototype data for each grass but cannot update their values in the Terrain inspector. Nothing I've tried so far seems to affect the grass prototypes assigned to the terrain. Here is a short code snipet:
DetailPrototype TempDetail = terrainToPopulate.terrainData.detailPrototypes[g];
TempDetail.bendFactor = BendFactor;
TempDetail.dryColor = ColorDry;
TempDetail.healthyColor = ColorHealthy;
TempDetail.maxHeight = HeightMax;
TempDetail.maxWidth = WidthMax;
TempDetail.minHeight = HeightMin;
TempDetail.minWidth = WidthMin;
TempDetail.noiseSpread = NoiseSpread;
TempDetail.usePrototypeMesh = true;
if (ApplyBillboard == true)
{
TempDetail.renderMode = DetailRenderMode.GrassBillboard;
}
else
{
TempDetail.renderMode = DetailRenderMode.Grass;
}
terrainToPopulate.terrainData.detailPrototypes[g] = TempDetail;
Note: I have an outer loop that is looping through each prototype [g] and setting the values. There are inspector parameters that control the setting of each value accordingly.
Your answer
Follow this Question
Related Questions
How do you make the material in the Terrain detail prototype properties update after runtime? 1 Answer
Preserving terrain details after stopping game. 0 Answers
Why does assigning heightmapResolution increase the size of my terrain? 2 Answers
Can unity stream (endless) terrain from server? 2 Answers
Terrain heightmap isn't smooth 0 Answers