- Home /
LineRenderer doesn't work in build
In the Unity Editor the Line Renderer component works perfectly fine and renders just as it should do but when it is built for Android then they disappear.
The material for the Line Renderer uses the Mobile/Particles/Additive shader
My code for the Line Renderer is here: string line;
StreamReader theReader = new StreamReader (fileName, Encoding.Default);
using (theReader) {
do {
line = theReader.ReadLine ();
file.Add (line);
if (line != null) {
string[] entries = line.Split ('>');
int firstNode = int.Parse (entries [0]);
int secondNode = int.Parse (entries [1]);
LineRenderer renderer = nodes [firstNode].GetComponent <LineRenderer> ();
renderer.SetPosition (0, nodes [firstNode].transform.position);
renderer.SetPosition (1, nodes [secondNode].transform.position);
}
} while (line != null);
theReader.Close();
}
Did you double checked that the shader is successfully loaded in the built player? Try adding that shader to the preloaded shader variant collection which is under Graphics setting.
Docs says:
Note that a shader might be not included into the player build if nothing references it! In that case, Shader.Find will work only in the editor, and will result in pink "missing shader" materials in the player build. Because of that, it is advisable to use shader references ins$$anonymous$$d of finding them by name. To make sure a shader is included into the game build, do either of: 1) reference it from some of the materials used in your scene, 2) add it under "Always Included Shaders" list in ProjectSettings/Graphics or 3) put shader or something that references it (e.g. a $$anonymous$$aterial) into a "Resources" folder."
So:
mat.shader = Shader.Find("$$anonymous$$yShader");
Unity does not find the reference there.
public Shader myShader;
mat.shader = myShader;
Unity has a reference from the variable so it will add it to the build.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Line Renderer not showing in Builds (Standalone, Mobile and Web) 0 Answers
Linerenderer pink and not working after build .exe 1 Answer
Can't Build PC Standalone due to multiple namespace script errors but playable in editor 1 Answer
Setting default quality level for WebGL Build not working 0 Answers