Question by
FullVisionDalton · Jul 19, 2018 at 09:43 AM ·
editorbuildlinerendererline
Line Renderer not showing in build mode
I make line with this script
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (line == null)
{
CreateLine();
}
//get the mouse position
mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = -25;
//set the start point and end point of the line renderer
line.SetPosition(0, mousePos);
line.SetPosition(1, mousePos);
}
//if line renderer exists and left mouse button is click exited (up)
else if (Input.GetMouseButtonUp(0) && line)
{
mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = -25;
//set the end point of the line renderer to current mouse position
line.SetPosition(1, mousePos);
//set line as null once the line is created
line = null;
currLines++;
}
//if mouse button is held clicked and line exists
else if (Input.GetMouseButton(0) && line)
{
mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = -25;
//set the end position as current position but dont set line as null as the mouse click is not exited
line.SetPosition(1, mousePos);
}
}
private void CreateLine()
{
line = new GameObject("Line" + currLines).AddComponent<LineRenderer>();
//set the number of points to the line
line.positionCount = 2 ;
line.startWidth = 0.10f;
line.endWidth = 0.10f;
//render line to the world origin and not to the object's position
line.useWorldSpace = false;
line.startColor = Color.cyan;
line.transform.parent = gameLine.transform;
}
In editor lines works normally and they are shown on screen, but when i made a build the lines are not shown and i don't understend why. Someone can help me?
Comment
Your answer
Follow this Question
Related Questions
What BuildTargetGroup option is the right for a linux build? 1 Answer
The variables modified in the inspector are not kept on build 0 Answers
Trouble pixelating a dynamic line. 0 Answers
Extremely Low FPS in Editor, smooth in Build. how to fix? 3 Answers
Score counting works in editor but not when I build it! 0 Answers