Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ProjectBackup/Unity/Landmass Generation/Library/PackageCache/com.unity.visualscripting@1.7.6/Documentation~/vs-add-subgraph.md
2022-11-12 13:10:03 +01:00

2.9 KiB

Add a Subgraph to a Script Graph

A Subgraph is a Script Graph nested inside of another Script Graph. A Subgraph appears as a single node inside the parent Script Graph.

You can add a Subgraph to a Script Graph in two ways: create an entirely new Script Graph, or add an existing Script Graph file.

Add a new Subgraph to a Script Graph

To add a new blank Subgraph to an existing Script Graph:

  1. With a Script Graph open in the Graph window, in the Graph Editor, right-click an empty area to open the fuzzy finder and go to Nesting > Subgraph.

  2. In the Graph Inspector, choose the Source for your Subgraph:

    • Embed: The Subgraph only exists on the Subgraph node. You can only modify the Subgraph from the node in its parent graph.
    • Graph: The Subgraph exists in a separate file. You can modify the Subgraph outside of its parent graph and reuse the graph in other areas of your application.

    Tip

    If the Graph Inspector isn't visible in the Graph window, select Graph Inspector (The Graph Inspector icon) from the toolbar.

  3. If you chose Graph, select New, enter a name for your graph file, and choose where you want to save it. Select Save.

An image of the Graph window, showing a new blank Subgraph node added to a Script Graph

To open your new Subgraph for editing, select Edit Graph.

Add an existing Script Graph as a Subgraph

To add an existing graph file as a Subgraph in a Script Graph:

Note

You can't nest a Script Graph as a Subgraph in its own graph file.

  1. With a Script Graph open in the Graph window, in the Graph Editor, right-click an empty area to open the fuzzy finder and go to Nesting > Subgraph.

  2. In the Graph Inspector, set your Source to Graph.

    Tip

    If the Graph Inspector isn't visible in the Graph window, select Graph Inspector (The Graph Inspector icon) from the toolbar.

  3. In the Graph field, select the target icon and choose a compatible Script Graph from your project. You can also click and drag a Script Graph file from your Project window and drop it into the Graph field.

An image of the Graph window, showing a new Subgraph node created from an existing Script Graph added to another Script Graph file

Tip

For a faster way to add a Script Graph as a Subgraph, click and drag the Script Graph from your Project window into the Graph Editor to automatically create a Subgraph node.

Next steps

Once you've added a Subgraph to your Script Graph, define its Input and Output Triggers and Input and Output Data. For more information, see Add a Trigger or Data port to a Script Graph.