0
votes

I had a full project running and working up until yesterday. I added only one object to my scene and later removed it and re-saved the scene. I made no changes to my scripts.

Now, I keep getting this message:

NullReferenceException: Object reference not set to an instance of an object StartScript.OnMouseUp () (at Assets/StartScript.cs:14) UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)

All I do in this line of script is finding a gameobject and setting its transform.poistion= new Vector3(0,0,0); I keep getting an error that the transform of the object is null, but this object is still part of the game. I never touched it!

Do you know how to solve this problem? I'm working on Unity3D version 5.

1
Are you sure you find the Gameobject? have you chekc if it was returning null? - Matriac
and can you please post your code where you find te object and set its position? it would help for finding your error - Matriac
Post your code so we can help - JoRouss
How are you finding the GameObject? by tag? by name? by Component? by Layer? Maybe one of these has change/deleted on the gameobject you are trying to find. - Rana
Actually ... a Vector3 can not be null. In Unity Vector3 is a struct which is a value type, only reference types can be null (unless ofc you wrap it up in a nullable, but thats a whole other story) - yes

1 Answers

0
votes

There is bug in Unity5 when you make a build. The tagging system isn't working well, all I had to do is to recreate my Tag list manually.