Legacy Documentation: Version 5.0
Scripting Tools
MonoDevelop

Console

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

The Console window (menu: Window > Console) shows errors, warnings and other messages generated by Unity. To aid with debugging, you can also show your own messages in the Console using the Debug.Log, Debug.LogWarning and Debug.LogError functions.

The toolbar of the console window has a number of options that affect how messages are displayed.

The Clear button removes any messages generated from your code but retains compiler errors. You can arrange for the console to be cleared automatically whenever you run the game by enabling the Clear On Play option.

You can also change the way messages are shown and updated in the console. The Collapse option shows only the first instance of an error message that keeps recurring. This is very useful for runtime errors, such as null references, that are sometimes generated identically on each frame update. The Error Pause option will cause playback to be paused whenever Debug.LogError is called from a script (but note that Debug.Log will not pause in this way). This can be handy when you want to freeze playback at a specific point in execution and inspect the scene.

Finally, there are two options for viewing additional information about errors. The Open Player Log and Open Editor Log items on the console tab menu access Unity’s log files which record details that may not be shown in the console. See the page about Log Files for further information.

Obsolete API Warnings and Automatic Updates

Among other messages, Unity shows warnings about the usage of obsolete API calls in your code. For example, Unity once had “shortcuts” in MonoBehaviour and other classes to access common component types. So, for example, you could access a Rigidbody on the object using code like:

    // The "rigidbody" variable is part of the class and not declared in the user script.
    Vector3 v = rigidbody.velocity;

These shortcuts have been deprecated, so you should now use code like:

    // Use GetComponent to access the component.
    Rigidbody rb = GetComponent<Rigidbody>();
    Vector3 v = rb.velocity;

When obsolete API calls are detected, Unity will show a warning message about them. When you double-click this message, Unity will attempt to upgrade the deprecated usage to the recommended equivalent automatically.

Scripting Tools
MonoDevelop