Hi,
I have a problem with this error in title. I have two GameObjects: Plane and Dot. Plane has attached DotsScript and Dot has attached Click script like a component. Both writed in C#.
I want call method, which is in DotsScript from Click script. So (like in the tutorial) I have public GameObject plane and in editor I attached Plane gameobject. In code I try this (again, exactly like in tutorial):
public class Click : MonoBehaviour {
public Vector3 startPoint;
public GameObject plane;
private DotsScript ds;
void Awake () {
ds = plane.GetComponent<DotsScript>();
}
void OnMouseDown ()
{
startPoint = gameObject.transform.position;
ds.SetClickPoint(startPoint);
}
}
In Editor everything works like a charm. When I build project on Android or on Windows I get this Error in output_log.txt:
NullReferenceException: Object reference not set to an instance of an object
at DotsScript.SetClickPoint (Vector3 point) [0x00000] in <filename unknown>:0
at Click.OnMouseDown () [0x00000] in <filename unknown>:0
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UnityEngine.HitInfo:SendMessage(String)
UnityEngine.SendMouseEvents:SendEvents(Int32, HitInfo)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32, Int32)
(Filename: Line: -1)
Can you help me, please?
It looks like the error is in DotsScript not in Click. You might edit your question and add the DotsScript code.
– robertbu