NullReferenceException: Stack trace#

Stack traces are reports of the path code took to get to an execution point. You must understand stack traces before solving runtime exceptions.

Click on an error in the Console window to see the full stack trace.


NullReferenceException: Object reference not set to an instance of an object
Example.Foo () (at Assets/Scripts/Example.cs:14 )

The key information to look for in a stack trace is the file name, method name, and line number.
Information is presented newest to oldest, the path the code took to get to here.

If the stack trace isn't leading you to a valid line of code: save, make sure your code has recompiled (there are no compiler errors), and cause the exception again. Double-click on an error that contains a stack trace involving user code to be taken to that line.

You can find a more detailed breakdown of stack traces here.

I understand stack traces.