docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
Show / Hide Table of Contents
  • About Visual Scripting
    • Configure project settings
      • Add or remove available nodes
      • Add or remove types
      • Create or restore a backup
    • Choose a control scheme
    • Configure your preferences
    • Update Visual Scripting
    • Version control systems
    • Use Visual Scripting with Unity Cloud Build
  • Basic concepts in Visual Scripting
    • The interface
    • Nodes
    • Graphs
      • Subgraphs and State Units
      • Transitions
    • Script Machines and State Machines
    • Object types
      • Custom types
    • Variables
  • Develop application logic with Script Graphs
    • Create a new graph file
      • Create a new blank graph with the Project window
      • Create a new unassigned graph with the empty graph creation flow
      • Create and assign a graph to an existing GameObject
      • Create and assign a graph to a new GameObject
      • Create a graph on a Script Machine or State Machine
    • Attach a graph file to a Script Machine or State Machine
    • Open a graph file
      • Add a node to a Script Graph
      • Connect nodes in a Script Graph
      • Create and add a variable to a Script Graph
      • Create node groups
      • Add comments to a graph
    • Add a Subgraph to a Script Graph
      • Add a Trigger or Data port to a Script Graph
    • Add a State Unit to a Script Graph
    • Custom Events
      • Add a Custom Event node
      • Add a Trigger Custom Event node
    • Capture user input in an application
      • Capture input using the Input Manager
      • Add and configure a Player Input component
      • Capture input using the Input System package
    • Use relations to debug
      • Predictive and live debugging
      • Working with debug messages
    • Live edit
      • Live edit during runtime
  • Develop logic transitions with state graphs
    • Create a new state
    • Create a transition between states
  • Advanced customization and development
    • Refactor a C# script with Visual Scripting
      • Add the RenamedFrom attribute to a C# script
    • Custom C# nodes
      • Create a new simple Custom C# node
      • Add ports to your Custom C# node
      • Add logic to your Custom C# node
      • Add relations to your Custom C# node
      • Add documentation to your Custom C# node
      • Custom C# node attributes reference
    • Create a Custom Scripting Event node
      • Create a Custom Scripting Event Sender node
      • Trigger a Custom Scripting Event from a C# script
      • Listen to a Custom Scripting Event from a C# script
    • Use a custom type
      • Add the Inspectable attribute to a custom type
      • Create a custom PropertyDrawer for a custom type
  • Node reference
    • This node
    • Control node
    • Time node
    • Events
      • Event nodes
      • Input Event nodes
        • On Input System Event Button
        • On Input System Event Float
        • On Input System Event Vector 2
        • On Button Input
        • On Keyboard Input
        • On Mouse Down
        • On Mouse Drag
        • On Mouse Enter
        • On Mouse Exit
        • On Mouse Input
        • On Mouse Over
        • On Mouse Up As Button
        • On Mouse Up
    • Variable node
    • Nulls node
    • Formula node
    • Nesting
      • Input node
      • Output node
      • State Unit node
      • Subgraph node
    • Script graph nodes
    • State graph nodes
  • Developer's guide
  • Known Issues

Script Graph nodes

Visual scripting has four nodes that you can use to identify and manipulate the Script Graphs assigned to a GameObject and its Script Machines:

  • Set Script Graph
  • Has Script Graph
  • Get Script Graph
  • Get Script Graphs

Set Script Graph

You can use the Set Script Graph node to assign a Script Graph to a specific Script Machine, or to the first Script Machine attached to a specific GameObject.

The Set Script Graph node

Label Item Description
The letter A in a blue circle, matching the label on the Set Script Graph node image. Node Parameters > Container type Specifies whether the Target is a GameObject or Script Machine.
The letter B in a blue circle, matching the label on the Set Script Graph node image. Input Ports > Enter (Input Trigger) The execution input trigger for the node.
The letter C in a blue circle, matching the label on the Set Script Graph node image. Input Ports > Target (GameObject or Script Machine) The GameObject or Script Machine where the node sets the Graph.
The letter D in a blue circle, matching the label on the Set Script Graph node image. Input Ports > Graph (Script Graph Asset) The Script Graph the node sets on the Target.
The letter E in a blue circle, matching the label on the Set Script Graph node image. Output Ports > Exit (Output Trigger) The execution output trigger.
The letter F in a blue circle, matching the label on the Set Script Graph node image. Output Ports > Graph (Script Graph Asset; Optional) Outputs the Graph.

Setting the required node parameters and inputs

The Set Script Graph node has one required input parameter, called Container Type, which is set using the dropdown in the node's header. The Container Type specifies what component type the node should expect as an input for its Target:

  • If you choose GameObject, the node expects to receive a GameObject, and assigns the graph to the first Script Machine attached to that GameObject.

  • If you choose Script Machine, the node expects to receive a Script Machine, and you can specify the exact Script Machine where you want to set your Script Graph.

Depending on which Container Type you select, the icon displayed next to the Target input port on the node changes:

Container Type Target Icon
GameObject The GameObject icon
Script Machine The Script Machine icon

The node has three input ports, located on the left side. The first port, Enter, connects to the node that should start the execution of the Set Script Graph node.

The other two ports collect the Set Script Graph node's required input data:

  • The Target, or the GameObject or Script Machine where you want to set a Script Graph.

  • The Graph, or the Script Graph to assign to the GameObject or Script Machine.

Outputs

The Set Script Graph node has two output ports, located on the right side.

The first port, Exit, establishes the connection to the node that should execute after the Set Script Graph node has finished.

The second port, Graph, can output the Script Graph that you assigned using the node.

Has Script Graph

The Has Script Graph node allows you to determine whether a GameObject or Script Machine has a specific Script Graph assigned to it.

The Has Script Graph node

Label Item Description
The letter A in a blue circle, matching the label on the Has Script Graph node image. Node Parameters > Container type Specifies whether the Target is a GameObject or Script Machine.
The letter B in a blue circle, matching the label on the Has Script Graph node image. Input Ports > Enter (Input Trigger) The execution input trigger for the node.
The letter C in a blue circle, matching the label on the Has Script Graph node image. Input Ports > Target (GameObject or Script Machine) The GameObject or Script Machine where the node sets the Graph.
The letter D in a blue circle, matching the label on the Has Script Graph node image. Input Ports > Graph (Script Graph Asset) The Script Graph the node sets on the Target.
The letter E in a blue circle, matching the label on the Has Script Graph node image. Output Ports > Exit (Output Trigger) The execution output trigger.
The letter F in a blue circle, matching the label on the Has Script Graph node image. Output Ports > Graph (Script Graph Asset; Optional) Outputs the Graph.

Setting the required node parameters and inputs

The Has Script Graph node has one required input parameter, called Container Type, which is set using the dropdown in the node's header. The Container Type specifies what component type the node should expect as an input for its Target:

  • If you choose GameObject, the node expects to receive a GameObject, and checks for the graph on the first Script Machine attached to that GameObject.

  • If you choose Script Machine, the node expects to receive a Script Machine, and you can specify the exact Script Machine where you want to check for the Script Graph.

Depending on which Container Type you select, the icon displayed next to the Target input port on the node changes:

Container Type Target Icon
GameObject The GameObject icon
Script Machine The Script Machine icon

The node has three input ports, located on the left side. The first port, Enter, connects to the node that should start the execution of the Has Script Graph node.

The other two ports collect the Has Script Graph node's required input data:

  • The Target, or the GameObject or Script Machine where you want to check for a Script Graph.

  • The Graph, or the Script Graph to search for on the GameObject or Script Machine.

Outputs

The Has Script Graph node returns true if it finds the specified Script Graph. Otherwise, it returns false.

You can use a control node connected to the Has Script Graph's output port to change what your script does next, based on the result from Has Script Graph. For more information about control nodes, see Control nodes.

Get Script Graph

The Get Script Graph node returns the first Script Graph set on a GameObject.

The Get Script Graph node

Label Item Description
The letter A in a blue circle, matching the label on the Get Script Graph node image. Input Ports > GameObject (GameObject) The GameObject where the node should retrieve a set Script Graph.
The letter B in a blue circle, matching the label on the Get Script Graph node image. Output Ports > Graph (Script Graph Asset) Outputs the first or only Script Graph set on the GameObject, or null if there is no set Script Graph.

Setting the required node parameters and inputs

The Get Script Graph node is a data node. It can't control any logic in your script, and is only used to return data.

The node has a single input port, located on the left side, which collects the node's required input data:

  • The GameObject where the node should retrieve the Script Graph. You can choose a specific GameObject, or leave the default selection as This to use the GameObject where your script is currently running.

Outputs

The Get Script Graph node has a single output port, located on the right side. The output port returns the GameObject's first set Script Graph, or null, if there is no set Script Graph.

Note

The Get Script Graph node returns only the first Script Graph set on a GameObject. To return all Script Graphs set on a GameObject, use the Get Script Graphs node.

Get Script Graphs

The Get Script Graphs node returns a list of all Script Graphs set on a GameObject.

The Get Script Graphs node

Label Item Description
The letter A in a blue circle, matching the label on the Get Script Graph node image. Input Ports > GameObject (GameObject) The GameObject where the node should retrieve a list of set Script Graph.
The letter B in a blue circle, matching the label on the Get Script Graph node image. Output Ports > Graph (List of Script Graph Asset) Outputs a list of all Script Graphs set on the GameObject, or an empty list if there are no set Script Graphs.

Setting the required node parameters and inputs

The Get Script Graphs node is a data node. It can't control any logic in your script, and is only used to return data.

The node has a single input port, located on the left side, which collects the node's required input data:

  • The GameObject where the node should retrieve a list of Script Graphs. You can choose a specific GameObject, or leave the default selection as This to use the GameObject where your script is currently running.

Outputs

The Get Script Graphs node has a single output port, located on the right side. The output port returns a list of all set Script Graphs for the GameObject, or an empty list, if there are no set Script Graphs.

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