🤔

Stack traces#

Stack traces are reports of the path code took to get to an execution point. Compiler errors and runtime exceptions will generally be accompanied by a stack trace. Stack traces are vital tools that give context to errors, and are the first step to understanding cause.

information

If stack traces are not appearing, change the Stack Trace Logging1 setting in the Console window's context menu back to Script Only.

Usage#

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

error

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.

Error locations#

You can usually double-click an error to be taken to the location, but this may not always be correct. Code changes can cause a location mismatch, as can miscellaneous reporting issues. Errors may also be thrown deeper than the cause itself, for example an ArgumentException may be reported inside a method, when it's the invalid argument that matters. If you have a runtime error, you can debug the issue to narrow down the issue further.

Details#

Compiler errors#

error

Assets\Scripts\Example.cs(80,9): error CS1002: ; expected

Compiler errors include a column number, but don't include the method name. Most IDEs will display the line and column number of the current selection in the bottom right as line:column.

Traces from native code#

UnassignedReferenceException: The variable pivot of Rotator has not been assigned. You probably need to assign the pivot variable of the GeneralRotationTest script in the inspector. UnityEngine.Transform.get_rotation () (at <cc54933d6df84ff08e916a4036d0b6c6>:0) Rotator.Update () (at Assets/Scripts/Rotator.cs:23)

Stack traces from DLLs or native locations may show a hash and no line number. As you will not be editing these files, this can be ignored. Look at the last location in user code when troubleshooting.

Properties#

If a method starts with get_ or set_ then it is a property with a name matching the suffix.

  1. This setting is shared in EditProject SettingsPlayer, and also effects log details in builds.