- Home /
LineRenderer not instantiating on iOS or Xcode, Works fine in editor and Unity Remote
Hi Everyone,
I'm setting it up so the player can draw a path for the units to follow on a terrain. I have created a linerenderer prefab and assigned it to the script in the gameobject. When playing the game in the editor and through the unity remote the line renderer works correctly. when I try running through Xcode I get an error saying the line renderer is null. I have no idea why it would work in the editor and in the editor with the unit remote but then some how loose the variable through xcode.
If I remove the instantiate line it stores the path in the list just fine and the unit moves correctly. Is there some build option that might be causing this?
Thanks
Here's the code: public LineRenderer path; private LineRenderer newPath; private Vector3 pathPos;
void StartPath()
{
Ray ray;
RaycastHit hit;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray,out hit,1000,1<<8))
{
if(Physics.SphereCast(ray,0.5f,out hit,200))
{
if(hit.collider.gameObject.tag == "Unit")
{
drawingPath = true;
newPath =Instantiate(path,selectedUnit.transform.position,selectedUnit.transform.rotation) as LineRenderer;
curPathNum = 0;
newPath.SetPosition(0,selectedUnit.transform.position);
newPath.SetPosition(1,selectedUnit.transform.position);
hasPath = true;
pathPos = selectedUnit.transform.position;
}
}
}
}
}