docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Predictive and Live Debugging

    Note

    For versions 2019/2020 LTS, download the Visual Scripting package from the Unity Asset Store.

    Visual scripting can predict and indicate nodes in the script that can cause an error before entering play mode. It also analyzes your graphs to anticipate missing components or null references. If an error occurs at runtime, visual scripting pin-points the source of the error by highlighting it in the graph.

    Predictive Debugging

    When a node is not properly configured or may cause an error, it is colored yellow. When a node is certain to cause an error, it is colored orange. In both cases you should examine the node and make the required changes until it turns back to its normal color.

    Example: The Log node is colored orange because it's missing the Message that it should output to the console.

    The Log node is colored orange because it's missing the Message that it should output to the console.

    If you connect the result of A + B to Message, the Log node goes back to normal. However, the Add node turns orange, because it's missing its first operand, A.

    The Add node is missing an operand, so it's orange.

    If values are provided for both operands, all colors return to normal.

    All nodes are in normal color, because there are no missing operands.

    The B input port does not need to be connected as it has a default inline value.

    Null References

    Null reference exceptions are very common. They happen when a parameter expects a value, but it receives "nothing", or in scripting lingo, "null".

    Visual scripting attempts to predict null references if the Predict Potential Null References option is checked in Unity > Preferences > Visual Scripting > Flow Graph.

    Example: Even though the Destroy node has an inline value, as it is set to "None" (null), it is colored orange.

    The Null node's inline value is set to None, so it's displayed in orange.

    There are some rarer nodes that allow for null parameters. Unfortunately, because there is no way to know that from codebase analysis, visual scripting colors them orange as a false positive. If this is a recurring issue, turn off Predict Potential Null References.

    Missing Components

    When nodes are used that require components and pass a game object or a component that does not have the specified component, the node is colored yellow as a warning. For example, even though there are default values for each value input of the Add Force node, visual scripting detects that the owner GameObject doesn't have a rigidbody and provides a warning.

    The owner GameObject doesn't have a rigidbody, which is a required component, so the node is in yellow.

    Visual scripting does not color the node orange because it is possible to add components to game objects at runtime, so the node is not guaranteed to cause a crash if you add the required component before calling it. If this use case happens often in the project, you can disable Predict Potential Missing Components debugging from Unity > Preferences > Visual Scripting > Flow Graphs.

    Live Debugging

    When in play mode, the currently active nodes are highlighted in blue. If an error occurs, the node that caused it is highlighted in red.

    Example: The following is an example of a faulty graph. The result logs "my 3rd third favorite fruit" to the console when you press space.

    The List node has an index value of 3, but the list of strings stops at index 2.

    Here's what happens when play is selected and the object is clicked.

    The List node is in red, because it caused an error.

    All nodes are highlighted in blue as soon as you click because they were activated. However, there was an error in the console.

    The console shows an error of Index out of range.

    Visual scripting highlights the faulty node in red.

    A common mistake is to assume array indices start at 1, whereas they actually start at 0. In scripting, indices are always zero-based; the first item is at index 0, the second at index 1, the third at index 2, etc. To get third item, write 2 in the field.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)