- Home /
Scripted detaillayer prototypes won't show in build.
Hello there,
I've found an issue with the terrain detaillayers. Script-added detaillayer prototypes won't show in the windows build.
As a test i've created the detaillayers in following way:
1) Added detaillayer prototypes trough the terrain tools (both textures and vertex-lit).
2) Added detaillayer prototypes to the same terrain with the following script (snippet):
DetailPrototype[] oldDetailPrototype = terrain.terrainData.detailPrototypes;
DetailPrototype[] newDetailPrototype = new DetailPrototype[(terrain.terrainData.detailPrototypes.Count() + gameObjectList.Count())];
int[] referencelist = new int[gameObjectList.Count()];
for (int i=0;i<terrain.terrainData.detailPrototypes.Count();i++) {
newDetailPrototype[i] = oldDetailPrototype[i];
}
int counter = 0;
int j = terrain.terrainData.detailPrototypes.Count();
foreach(GameObject obbie in gameObjectList) {
DetailPrototype prototype = new DetailPrototype();
prototype.prototype = obbie;
prototype.dryColor = Color.black;
prototype.healthyColor = Color.black;
prototype.noiseSpread = 0.1f;
prototype.renderMode = DetailRenderMode.VertexLit;
prototype.usePrototypeMesh = true;
prototype.minWidth = 0.75f;
prototype.maxWidth = 1.0f;
prototype.minHeight = 0.75f;
prototype.maxHeight = 1.0f;
newDetailPrototype[j] = prototype;
referencelist[counter] = j;
j++;
counter++;
}
terrain.terrainData.detailPrototypes = newDetailPrototype;
terrain.terrainData.RefreshPrototypes();
terrain.Flush();
3) Both the tool-added and the script-added detail prototypes are then assigned trough a script to the detaillayers.
4) In the Unity editor both the tool-added and the script-added details appear on the terrain on runtime.
5) In a build only the tool-added details appear on the terrain on runtime
The runtime error log shows no errors or notices regarding this what so ever. Adding the prefabs in the resource folder makes no difference.
Do you have any idea why this issue appears? And do you have a possible solution for this?
Thanks in advance!
Now i've tested this on the following platforms:
Windows (32 and 64bit)
$$anonymous$$acOS
Webplayer
And none of them shows the detail layer prototypes added by the script while the IDE player does.
I'm having the same problem and were now on unity 5.3.1. What is going on?? I need to create grass at run time and it works fine in editor but comes out black or invisible in build.
Answer by GXMark · Apr 09, 2014 at 04:45 PM
I've tested the SplatPrototype, DetailPrototype in scripting at runtime (Editor and Seperate PC/MAC Build) and it all updates fine. This includes adding prototype then re-applying the prototypes for splats and modifying the detail prototype settings at runtime. I have heard there are issues with running this via a web player but have not investigated this build type yet.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Terrain building with errors 0 Answers
Culling Terrain detail objects by layer 0 Answers
DetailPrototype 1 Answer
build and run/ saved scene is not updated when application is loaded. 0 Answers