Follow

NullReferenceException

Symptoms

  • I am getting the error below appearing in my console:
NullReferenceException: Object reference not set to an instance of an 
object

Cause

This error is caused when an object is trying to be used by a script but does not refer to an instance of an object.

Resolution

To fix this example we can acquire a reference to an instance of the script using GameObject.Find to find the object it is attached to. We then use GetComponent to find the script component we want a reference to.

You can also double click the error to take you to the line of script where the error is occurring.

From there you can trace each object back to where they are assigned (if they have been assigned).

More Information

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.