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

Custom Events

Events trigger, or start, a chain of logic in a Script Graph based on a specific occurrence in your application. Some Event types, such as On Start or On Update, exist by default in Visual Scripting. These Event nodes tell Visual Scripting to run the nodes they're connected to after the Script Graph starts, or on every frame while the Script Graph is active.

You can also create your own custom Scripting Events to specify conditions for when a Script Graph's logic runs.

Visual Scripting has two types of custom Events:

  • Custom Event nodes: Use Custom Event nodes and Custom Event Trigger nodes to raise simple custom Events that don't require complex logic.

  • Custom Scripting Events: Create your own Custom Scripting Event nodes to raise more complex Event logic.

Custom Event nodes

Custom Event nodes are always accessible from the fuzzy finder. You don't need to write your own code to use these custom Events in a Script Graph. They don't require an event listener.

You can use the Custom Event node to create multiple custom Events, as long as you give each Event a unique name. You can also customize the number of arguments that the Custom Event node can send.

To configure a Custom Event node, you need to provide:

  • A unique name.

  • A GameObject.

  • The number of arguments the Custom Event receives.

For more information on how to configure and use a Custom Event node, see Add a Custom Event node.

To trigger a Custom Event, use a Custom Event Trigger node and provide the unique name of the Event. For more information, see Add a Custom Event Trigger node.

Visual Scripting displays errors in the Graph Inspector if the Custom Event node and a Custom Event Trigger node have different values for:

  • The name of the Event.
  • The provided GameObject for the Event.
  • The number of arguments for the Event.

An image of the Graph Editor and Graph Inspector. An On Keyboard Input node with its Key set to Space and its Action set to Hold connects to a Custom Event Trigger node. The node triggers the MyEvent Custom Event node, which connects to a Debug Log node to write the value of Arg. 0 to the console. The Custom Event Trigger node displays in red, because its Arguments field is set to 0, while the Custom Event node has its Arguments set to 2. The Graph Inspector displays an Index out of Range Exception error.

All arguments on a Custom Event Trigger node must have values, even if the Custom Event node doesn't give those values to another node. In the following example, Visual Scripting displays an error for both Arg. 0 and Arg. 1, even though Arg. 1 isn't used.

An image of the Graph Editor and Graph Inspector. An On Keyboard Input node with its Key set to Space and its Action set to Hold connects to a Custom Event Trigger node. The node triggers the MyEvent Custom Event node, which connects to a Debug Log node to write the value of Arg. 0 to the console. The Custom Event Trigger node displays in orange because its Arg. 0 and Arg. 1 input ports don't receive any input values. The Graph Inspector displays two warnings that state that Arg. 0 is missing, and Arg. 1 is missing.

Custom Scripting Events

You can create a Custom Scripting Event node with a C# script. With C#, you can customize all aspects of your Custom Scripting Event, such as which category or categories to use for your node in the fuzzy finder. For more information, see Create a Custom Scripting Event node.

An image of the Graph Editor, that displays a Custom Scripting Event node and a Custom Scripting Event Sender node. An On Keyboard Input node with its Key set to Space and its Action set to Down connects to the Send My Custom Event node. When a user presses the Spacebar, the graph triggers the Send My Custom Event node, which triggers the On My Custom Event node. The On My Custom Event node connects to a Debug Log node, which logs the Result to the console.

To use and trigger the Event, code a Custom Scripting Event Sender node or another C# script:

  • For more information on how to send or trigger an Event with a node in a Script Graph, see Create a Custom Scripting Event Sender node.

  • For more information on how to send or trigger an Event with code, see Trigger a Custom Scripting Event from a C# script.

You can also use a C# script to listen to or receive your Event after you trigger it in a Script Graph. You can use your receiver script to trigger more logic in your application. For more information, see Listen to a Custom Scripting Event from a C# script.

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