Unity-jump-proj
@ -0,0 +1,201 @@
|
||||
* [About Visual Scripting](index.md)
|
||||
|
||||
*[Configure project settings](vs-configuration.md)
|
||||
|
||||
*[Add or remove available nodes](vs-add-remove-node-library.md)
|
||||
|
||||
*[Add or remove types](vs-add-remove-type-options.md)
|
||||
|
||||
*[Create or restore a backup](vs-create-restore-backups.md)
|
||||
|
||||
*[Choose a control scheme](vs-control-schemes.md)
|
||||
|
||||
*[Configure your preferences](vs-set-preferences.md)
|
||||
|
||||
*[Update Visual Scripting](vs-update.md)
|
||||
|
||||
*[Version control systems](vs-version-control.md)
|
||||
|
||||
*[Use Visual Scripting with Unity Cloud Build](vs-aot.md)
|
||||
|
||||
* [Basic concepts in Visual Scripting](vs-basic-concepts.md)
|
||||
|
||||
*[The interface](vs-interface-overview.md)
|
||||
|
||||
*[Nodes](vs-nodes.md)
|
||||
|
||||
*[Graphs](vs-graph-types.md)
|
||||
|
||||
*[Subgraphs and State Units](vs-nesting-subgraphs-state-units.md)
|
||||
|
||||
*[Transitions](vs-transitions.md)
|
||||
|
||||
*[Script Machines and State Machines](vs-graph-machine-types.md)
|
||||
|
||||
*[Object types](vs-types.md)
|
||||
|
||||
*[Custom types](vs-custom-types.md)
|
||||
|
||||
*[Variables](vs-variables.md)
|
||||
|
||||
* [Develop application logic with Script Graphs](vs-script-graphs-intro.md)
|
||||
|
||||
*[Create a new graph file](vs-create-graph.md)
|
||||
|
||||
*[Create a new blank graph with the Project window](vs-create-graph-project-window.md)
|
||||
|
||||
*[Create a new unassigned graph with the empty graph creation flow](vs-create-graph-unassigned-flow.md)
|
||||
|
||||
*[Create and assign a graph to an existing GameObject](vs-create-graph-assign-existing-gameobject.md)
|
||||
|
||||
*[Create and assign a graph to a new GameObject](vs-create-graph-assign-new-gameobject.md)
|
||||
|
||||
*[Create a graph on a Script Machine or State Machine](vs-create-graph-on-machine.md)
|
||||
|
||||
*[Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md)
|
||||
|
||||
*[Open a graph file](vs-open-graph-edit.md)
|
||||
|
||||
*[Add a node to a Script Graph](vs-add-node-to-graph.md)
|
||||
|
||||
*[Connect nodes in a Script Graph](vs-creating-connections.md)
|
||||
|
||||
*[Create and add a variable to a Script Graph](vs-add-variable-graph.md)
|
||||
|
||||
*[Create node groups](vs-groups.md)
|
||||
|
||||
*[Add comments to a graph](vs-sticky-notes.md)
|
||||
|
||||
*[Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md)
|
||||
|
||||
*[Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md)
|
||||
|
||||
*[Add a State Unit to a Script Graph](vs-nesting-add-state-unit.md)
|
||||
|
||||
*[Custom Events](vs-custom-events.md)
|
||||
|
||||
*[Add a Custom Event node](vs-add-custom-event-node.md)
|
||||
|
||||
*[Add a Trigger Custom Event node](vs-add-custom-event-node-trigger.md)
|
||||
|
||||
*[Capture user input in an application](vs-capture-player-input.md)
|
||||
|
||||
*[Capture input using the Input Manager](vs-capturing-player-inputs-old.md)
|
||||
|
||||
*[Add and configure a Player Input component](vs-capture-player-input-add-component.md)
|
||||
|
||||
*[Capture input using the Input System package](vs-capturing-player-inputs-new.md)
|
||||
|
||||
*[Use relations to debug](vs-relations.md)
|
||||
|
||||
*[Predictive and live debugging](vs-debugging.md)
|
||||
|
||||
*[Working with debug messages](vs-debug-messages.md)
|
||||
|
||||
*[Live edit](vs-live.md)
|
||||
|
||||
*[Live edit during runtime](vs-live-edit-runtime.md)
|
||||
|
||||
* [Develop logic transitions with state graphs](vs-state-graphs-intro.md)
|
||||
|
||||
*[Create a new state](vs-create-state.md)
|
||||
|
||||
*[Create a transition between states](vs-creating-transition.md)
|
||||
|
||||
* [Advanced customization and development](vs-advanced-topics-intro.md)
|
||||
|
||||
*[Refactor a C# script with Visual Scripting](vs-refactoring.md)
|
||||
|
||||
*[Add the RenamedFrom attribute to a C# script](vs-refactor-add-attribute.md)
|
||||
|
||||
*[Custom C# nodes](vs-create-custom-node.md)
|
||||
|
||||
*[Create a new simple Custom C# node](vs-create-custom-node-empty.md)
|
||||
|
||||
*[Add ports to your Custom C# node](vs-create-custom-node-add-ports.md)
|
||||
|
||||
*[Add logic to your Custom C# node](vs-create-custom-node-add-logic.md)
|
||||
|
||||
*[Add relations to your Custom C# node](vs-create-custom-node-add-relations.md)
|
||||
|
||||
*[Add documentation to your Custom C# node](vs-create-custom-node-add-docs.md)
|
||||
|
||||
*[Custom C# node attributes reference](vs-create-custom-node-attributes-reference.md)
|
||||
|
||||
*[Create a Custom Scripting Event node](vs-create-own-custom-event-node.md)
|
||||
|
||||
*[Create a Custom Scripting Event Sender node](vs-create-own-custom-event-send-node.md)
|
||||
|
||||
*[Trigger a Custom Scripting Event from a C# script](vs-create-own-custom-event-node-trigger-code.md)
|
||||
|
||||
*[Listen to a Custom Scripting Event from a C# script](vs-create-own-custom-event-listen-code.md)
|
||||
|
||||
*[Use a custom type](vs-using-custom-types.md)
|
||||
|
||||
*[Add the Inspectable attribute to a custom type](vs-add-inspectable-attribute-custom-types.md)
|
||||
|
||||
*[Create a custom PropertyDrawer for a custom type](vs-create-custom-drawer.md)
|
||||
|
||||
* [Node reference](vs-nodes-reference.md)
|
||||
|
||||
*[This node](vs-self.md)
|
||||
|
||||
*[Control node](vs-control.md)
|
||||
|
||||
*[Time node](vs-time.md)
|
||||
|
||||
*Events
|
||||
|
||||
*[Event nodes](vs-events-reference.md)
|
||||
|
||||
*[Input Event nodes](vs-input-nodes.md)
|
||||
|
||||
*[On Input System Event Button](vs-nodes-events-input-system-button.md)
|
||||
|
||||
*[On Input System Event Float](vs-nodes-events-input-system-float.md)
|
||||
|
||||
*[On Input System Event Vector 2](vs-nodes-events-input-system-vector2.md)
|
||||
|
||||
*[On Button Input](vs-nodes-events-on-button-input.md)
|
||||
|
||||
*[On Keyboard Input](vs-nodes-events-on-keyboard-input.md)
|
||||
|
||||
*[On Mouse Down](vs-nodes-events-on-mouse-down.md)
|
||||
|
||||
*[On Mouse Drag](vs-nodes-events-on-mouse-drag.md)
|
||||
|
||||
*[On Mouse Enter](vs-nodes-events-on-mouse-enter.md)
|
||||
|
||||
*[On Mouse Exit](vs-nodes-events-on-mouse-exit.md)
|
||||
|
||||
*[On Mouse Input](vs-nodes-events-on-mouse-input.md)
|
||||
|
||||
*[On Mouse Over](vs-nodes-events-on-mouse-over.md)
|
||||
|
||||
*[On Mouse Up As Button](vs-nodes-events-on-mouse-up-button.md)
|
||||
|
||||
*[On Mouse Up](vs-nodes-events-on-mouse-up.md)
|
||||
|
||||
*[Variable node](vs-variables-reference.md)
|
||||
|
||||
*[Nulls node](vs-nulls.md)
|
||||
|
||||
*[Formula node](vs-formula.md)
|
||||
|
||||
*[Nesting](vs-nesting-nodes.md)
|
||||
|
||||
*[Input node](vs-nesting-input-node.md)
|
||||
|
||||
*[Output node](vs-nesting-output-node.md)
|
||||
|
||||
*[State Unit node](vs-nesting-state-unit-node.md)
|
||||
|
||||
*[Subgraph node](vs-nesting-subgraph-node.md)
|
||||
|
||||
*[Script graph nodes](vs-scripts-reference.md)
|
||||
|
||||
*[State graph nodes](vs-states-reference.md)
|
||||
|
||||
* [Developer's guide](vs-developers-guide.md)
|
||||
|
||||
* [Known Issues](vs-editor-script-issues.md)
|
After Width: | Height: | Size: 697 B |
After Width: | Height: | Size: 648 B |
After Width: | Height: | Size: 682 B |
After Width: | Height: | Size: 645 B |
After Width: | Height: | Size: 560 B |
After Width: | Height: | Size: 573 B |
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 354 B |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 9.8 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 202 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 711 B |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 385 B |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 382 B |
After Width: | Height: | Size: 778 B |
After Width: | Height: | Size: 393 B |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 346 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 374 B |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 552 B |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,33 @@
|
||||
# About Visual Scripting
|
||||
|
||||
Use Visual Scripting to create logic for games or applications without hand-coded C# scripts. Visual Scripting uses visual, node-based graphs, which both programmers and non-programmers use to design final logic or create prototypes. Visual Scripting also has an API that programmers can use for more advanced tasks, or to create custom nodes for other team members.
|
||||
|
||||
Visual Scripting nodes can represent functions, operators, and variables. Connect these nodes from their ports with edges to design your logic visually.
|
||||
|
||||
## Installation
|
||||
|
||||
From Unity Editor version 2021.1 onward, Visual Scripting is installed by default as a package. For more information on packages, see the [Packages section](https://docs.unity3d.com/Manual/PackagesList.html) in the Unity User Manual.
|
||||
|
||||
For earlier versions of Unity, including 2019 LTS and 2020 LTS, you must install the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
## Configure Visual Scripting
|
||||
|
||||
> [!NOTE]
|
||||
> To use Visual Scripting in a project for the first time, you must [initialize it](vs-configuration.md#Initialize) from the Editor's [Project Settings](https://docs.unity3d.com/Manual/comp-ManagerGroup.html) window.
|
||||
|
||||
To get started with Visual Scripting, [configure your project settings](vs-configuration.md) and [configure your preferences](vs-set-preferences.md).
|
||||
|
||||
## Choose a control scheme
|
||||
|
||||
Learn the common keyboard shortcuts and [choose a control scheme](vs-control-schemes.md) that suits your needs.
|
||||
|
||||
## Update Visual Scripting
|
||||
|
||||
Learn how to [update Visual Scripting](vs-update.md) and [create and restore backups](vs-create-restore-backups.md).
|
||||
|
||||
## System requirements
|
||||
|
||||
Visual Scripting has no external dependencies.
|
||||
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: ff-add-node
|
||||
---
|
||||
|
||||
Right-click anywhere in the [Graph Editor](../../vs-interface-overview.md#the-graph-editor) to open the fuzzy finder. Then, select your node in the fuzzy finder to add it to your graph.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-graph-w-node
|
||||
---
|
||||
|
||||
[Open a Script Graph](../../vs-open-graph-edit.md) where you've already added your node.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: vs-tasks-note-end
|
||||
---
|
||||
|
||||
The examples below are based on the previous examples for a Custom C# node. For more information, see [Create a new simple Custom C# node](../../vs-create-custom-node-empty.md).
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: right-click-project
|
||||
---
|
||||
|
||||
Right-click a folder in the Project window's folder list or anywhere in the Project window's preview pane.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: tasks-note-end
|
||||
---
|
||||
|
||||
The examples below are based on the previous example to create a Custom Scripting Event node. For more information, see [Create a Custom Scripting Event node](../../vs-create-own-custom-event-node.md)
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-desc-end
|
||||
---
|
||||
|
||||
It triggers the next node connected to it after the action occurs in the application. It doesn't send or receive any other data.
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
title: nodes-input-output-trigger
|
||||
---
|
||||
|
||||
<tr>
|
||||
<td><strong>Trigger</strong></td>
|
||||
<td>Output Trigger</td>
|
||||
<td>The control output port. Make a connection to specify what Visual Scripting should do after the configured Input event occurs in your application.</td>
|
||||
</tr>
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-note-manual
|
||||
---
|
||||
|
||||
node is an [Input Manager](https://docs.unity3d.com/Manual/class-InputManager.html) node. For more information about how to use the Input Manager with Visual Scripting, see [Capture user input in an application](../../vs-capture-player-input.md).
|
@ -0,0 +1,32 @@
|
||||
---
|
||||
title: nodes-input-action-change
|
||||
---
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="4"><strong>Input Action Change Type</strong></td>
|
||||
<td rowspan="4">Input Action Change Option</td>
|
||||
<td colspan="2">Set an Input Action Change Type to choose the interaction type that triggers the node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Pressed</strong></td>
|
||||
<td>The node triggers when a user presses the button from the selected <strong>Input Action</strong> input asset.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hold</strong></td>
|
||||
<td>The node triggers when a user holds the button from the selected <strong>Input Action</strong> input asset.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Released</strong></td>
|
||||
<td>The node triggers when a user releases the button from the selected <strong>Input Action</strong> input asset.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: nodes-input-system-output-trigger-port
|
||||
---
|
||||
<tr>
|
||||
<td><strong>Trigger</strong></td>
|
||||
<td>Output Trigger</td>
|
||||
<td>The control output port. Make a connection to specify what Visual Scripting does after the configured Player Input event, such as a button press, occurs in the application.</td>
|
||||
</tr>
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: nodes-input-system-ports
|
||||
---
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :------- | :------------- |
|
||||
| **Target** | Player Input | The Player Input component that Visual Scripting uses to display a list of input actions. The default is **This**, which is the Player Input component attached to the GameObject where Visual Scripting runs the Script Graph. You can also connect a node that outputs a Player Input component.|
|
||||
| **Input Action** | Input Action | An input action. Use the dropdown to select an input action from the Player Input component specified in **Player Input**, or connect a node that outputs an input action.|
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-note-package
|
||||
---
|
||||
|
||||
is an [Input System package](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest) node. For more information about how to use the Input System package in Visual Scripting, see [Capture user input in an application](../../vs-capture-player-input.md).
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-additional-settings
|
||||
---
|
||||
|
||||
node has additional settings. Access these settings from the [Graph Inspector](../vs-interface-overview.md#the-graph-inspector):
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-controls
|
||||
---
|
||||
|
||||
node has the following controls:
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
title: nodes-coroutine
|
||||
---
|
||||
|
||||
<tr>
|
||||
<td><strong>Coroutine</strong></td>
|
||||
<td>Toggle</td>
|
||||
<td>Enable <strong>Coroutine</strong> if you want Visual Scripting to run this node and any of its connected nodes as a coroutine. Coroutine nodes don't execute all their code in a single frame, so they can spread an effect over several frames. Coroutines can also help optimize your code. For more information on coroutines, see the Unity User Manual section on <a href="https://docs.unity3d.com/Manual/Coroutines.html">Coroutines</a>.</td>
|
||||
</tr>
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-inputs
|
||||
---
|
||||
|
||||
node has the following input ports:
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-outputs
|
||||
---
|
||||
|
||||
node has the following output ports:
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: nodes-related
|
||||
---
|
||||
The following nodes are related or similar to the
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-single-control
|
||||
---
|
||||
|
||||
node has one control:
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-single-input
|
||||
---
|
||||
|
||||
node has one input port:
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: nodes-single-output
|
||||
---
|
||||
|
||||
node has one output port:
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: blackboard-tip
|
||||
---
|
||||
|
||||
> [!TIP]
|
||||
> If the Blackboard isn't visible in the Graph window, select **Blackboard** () from the toolbar.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: create-c-script
|
||||
---
|
||||
|
||||
Go to **Create** > **C# Script**.
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: graph-inspector-tip-html
|
||||
---
|
||||
|
||||
|
||||
<div class="TIP"><h5>TIP</h5><p>If the Graph Inspector isn't visible in the Graph window, select <strong>Graph Inspector</strong> (<img src="../images/vs-graph-inspector-icon.png" alt="The Graph Inspector icon. A circle with a lower-case letter 'i' inside.">) from the toolbar.</p></div>
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: graph-inspector-tip
|
||||
---
|
||||
|
||||
> [!TIP]
|
||||
> If the Graph Inspector isn't visible in the Graph window, select **Graph Inspector** () from the toolbar.
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: open-existing-external-code
|
||||
---
|
||||
|
||||
Double-click the C# file. Unity opens the file in the program you specified in your preferences, under **External Script Editor**.
|
||||
|
||||
> [!NOTE]
|
||||
> For more information on script editors in Unity, see the [Integrated development environment (IDE) support](https://docs.unity3d.com/Manual/ScriptingToolsIDEs.html) in the Unity User Manual.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-fuzzy-finder
|
||||
---
|
||||
|
||||
Right-click anywhere in the Graph Editor to open the fuzzy finder.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-graph-inspector
|
||||
---
|
||||
|
||||
Select **Graph Inspector** () from the toolbar.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-graph
|
||||
---
|
||||
|
||||
[Open a graph file](../vs-open-graph-edit.md) in the Graph window.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-hierarchy-window
|
||||
---
|
||||
|
||||
Go to **Window** > **General** > **Hierarchy**, or press Ctrl+4 (macOS: Cmd+4) to open the [Hierarchy window](https://docs.unity3d.com/Manual/Hierarchy.html).
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-inspector-window
|
||||
---
|
||||
|
||||
With the GameObject selected in the Hierarchy window, go to **Window** > **General** > **Inspector**, or press Ctrl+3 (macOS: Cmd+3) to open the [Inspector window](https://docs.unity3d.com/Documentation/Manual/UsingTheInspector.html).
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: open-new-external-code
|
||||
---
|
||||
|
||||
Double-click the new C# file. Unity opens the file in the program you specified in your preferences, under **External Script Editor**.
|
||||
|
||||
> [!NOTE]
|
||||
> For more information on script editors in Unity, see the [Integrated development environment (IDE) support](https://docs.unity3d.com/Manual/ScriptingToolsIDEs.html) in the Unity User Manual.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-project-settings
|
||||
---
|
||||
|
||||
Go to **Edit** > **Project Settings**.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-project-window
|
||||
---
|
||||
|
||||
Go to **Window** > **General** > **Project**, or press Ctrl+5 (macOS: Cmd+5) to open the [Project window](https://docs.unity3d.com/Manual/ProjectView.html).
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: open-state-menu
|
||||
---
|
||||
|
||||
With a State Graph [open in the Graph window](../vs-open-graph-edit.md), right-click on an empty space in the Graph Editor to open the context menu.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: regen-node-library
|
||||
---
|
||||
|
||||
Follow the process described in [Configure project settings](../vs-configuration.md#Regen) to regenerate your Node Library.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: return-unity
|
||||
---
|
||||
|
||||
Return to the Unity Editor.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: save-script
|
||||
---
|
||||
|
||||
Save your script file.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: visual-scripting-window
|
||||
---
|
||||
|
||||
Go to **Window** > **Visual Scripting** > **Visual Scripting Graph**.
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: with-graph-open-ff
|
||||
---
|
||||
With a Script Graph [open in the Graph window](../vs-open-graph-edit.md), right-click on an empty space in the Graph Editor to open the fuzzy finder.
|
@ -0,0 +1,40 @@
|
||||
# Add a Custom Event Trigger node
|
||||
|
||||
You can use a Custom Event Trigger node to trigger a matching Custom Event node in your application. For more information on custom Events, see [Custom Events](vs-custom-events.md).
|
||||
|
||||
> [!NOTE]
|
||||
> Before you add a Custom Event Trigger node, you must add and configure a Custom Event node in a Script Graph. For more information, see [Add a Custom Event node](vs-add-custom-event-node.md).
|
||||
|
||||
To add a Custom Event Trigger node to a Script Graph:
|
||||
|
||||
1. [Open the Script Graph](vs-open-graph-edit.md) where you want to add a Custom Event Trigger node. This can be the same graph or a different graph from where you added a Custom Event node.
|
||||
|
||||
2. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)].
|
||||
|
||||
1. Go to **Events**.
|
||||
|
||||
1. Select the **Custom Event Trigger** node to add it to the graph.
|
||||
|
||||
3. In the **Name** input port's field, enter the name of the Custom Event node you want to trigger, exactly as it appears on the Custom Event node, through one of the following methods:
|
||||
|
||||
- Enter the name in the field next to the **Name** input port.
|
||||
- Attach a node that outputs the name as a string value to the **Name** input port.
|
||||
|
||||
4. In the **GameObject** field, indicated by the GameObject icon on the node, specify the GameObject that you want to trigger your Event. This doesn't have to be the same GameObject as the Custom Event node. Do one of the following:
|
||||
|
||||
- Select the object picker (circle icon) and select the GameObject.
|
||||
- Attach a node to the field's data input port that outputs the GameObject.
|
||||
- Leave the field as the default value of **This** to use the GameObject from your currently open Script Graph's Script Machine.
|
||||
|
||||
5. In the **Arguments** field, enter the number from your Custom Event node's **Arguments** field.
|
||||
|
||||
> [!NOTE]
|
||||
> All arguments on a Custom Event Trigger node must receive input values, even if the Custom Event node doesn't use those arguments. Otherwise, Visual Scripting displays an error in the Graph Inspector for the Custom Event Trigger node.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
You can [add more nodes](vs-add-node-to-graph.md) and [connect them](vs-creating-connections.md) to create the trigger logic for your Custom Event node in the graph.
|
||||
|
||||
You can also [create a Custom Scripting Event node](vs-create-own-custom-event-node.md).
|
@ -0,0 +1,47 @@
|
||||
# Add a Custom Event node
|
||||
|
||||
You can add a Custom Event node to a Script Graph to trigger specific logic after an Event occurs. For more information about custom Events, see [Custom Events](vs-custom-events.md).
|
||||
|
||||
> [!NOTE]
|
||||
> To use a Custom Event node, you must configure the node with the following instructions, then add a Custom Event Trigger node to your graph. For more information on how to add a Custom Event Trigger node, see [Add a Custom Event Trigger node](vs-add-custom-event-node-trigger.md)
|
||||
|
||||
To add a Custom Event node to a Script Graph:
|
||||
|
||||
1. [Open the Script Graph](vs-open-graph-edit.md) where you want to add a Custom Event node.
|
||||
|
||||
2. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)].
|
||||
|
||||
3. Go to **Events**.
|
||||
|
||||
4. Select the **Custom Event** node to add it to your graph.
|
||||
|
||||
5. In the **GameObject** field, indicated by the GameObject icon on the node, choose the GameObject where you want to create the Event. Do one of the following:
|
||||
|
||||
- Select the object picker (circle icon), and select a GameObject.
|
||||
- Attach a node to the field's data input port that outputs a GameObject.
|
||||
- Leave the field as the default value of **This** to use the GameObject where you attached your Script Graph to a Script Machine.
|
||||
|
||||
6. In the **Arguments** field, enter the number of arguments you want the custom Event to receive and pass to other nodes in your graph. The default value is 0. If you enter a number greater than 0, Visual Scripting adds the corresponding number of Output ports to the Custom Event node.
|
||||
|
||||
> [!NOTE]
|
||||
> Visual Scripting labels your first argument as `Arg. 0`.
|
||||
|
||||
7. Enter a unique name for the custom Event through one of the following methods:
|
||||
|
||||
- Enter a name in the field next to the **Name** input port.
|
||||
- Attach a node that outputs a string value to the **Name** input port.
|
||||
|
||||
In the following example, a custom Event called **On Damage** returns a single argument when it's triggered in a Script Graph.
|
||||
|
||||

|
||||
|
||||
|
||||
## Next steps
|
||||
|
||||
After you add a Custom Event node to your graph, [add more nodes to your graph](vs-add-node-to-graph.md) or [connect nodes](vs-creating-connections.md) to specify what happens after your Event triggers.
|
||||
|
||||
Then, [add a Custom Event Trigger node](vs-add-custom-event-node-trigger.md) to specify when to trigger the custom Event in your graph.
|
||||
|
||||
To create more complex logic for your custom Event, you can also [create a Custom Scripting Event node](vs-create-own-custom-event-node.md).
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
# Add the Inspectable attribute to a custom type
|
||||
|
||||
If you have access to the source code for a custom type, add the `[Inspectable]` attribute to its fields and classes. The `[Inspectable]` attribute makes these fields and classes accessible to the [Inspector window](https://docs.unity3d.com/Manual/UsingTheInspector.html) in the Unity Editor. You don't need to create a [custom PropertyDrawer](vs-create-custom-drawer.md) as Unity generates a basic UI for the custom type.
|
||||
|
||||
For more information about how to use custom types in Visual Scripting, see [Use a custom type](vs-using-custom-types.md) or [Custom types](vs-custom-types.md)
|
||||
|
||||
To add the `[Inspectable]` attribute to the source code for a custom type:
|
||||
|
||||
1. [!include[open-existing-external-code](./snippets/vs-open-existing-external-code.md)]
|
||||
|
||||
2. In your external editor, on a line above your `public class` definition, add the `[Inspectable]` attribute.
|
||||
|
||||
1. On a line above the properties you want to have available in the Unity Inspector, add the `[Inspectable]` attribute.
|
||||
|
||||
1. [!include[regen-node-library](./snippets/vs-regen-node-library.md)]
|
||||
|
||||
The following is an example of a public class, with fields `name` and `amount` that are accessible and can be modified through Unity's Inspector window.
|
||||
|
||||
```csharp
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
[Inspectable]
|
||||
public class MyClass
|
||||
{
|
||||
[Inspectable]
|
||||
public string name;
|
||||
|
||||
[Inspectable]
|
||||
public int amount;
|
||||
|
||||
public string dontShowThis;
|
||||
}
|
||||
|
||||
```
|
@ -0,0 +1,25 @@
|
||||
# Add a node to a Script Graph
|
||||
|
||||
All logic in a Script Graph starts with a node.
|
||||
|
||||
> [!TIP]
|
||||
> Depending on the method you used to create your Script Graph, you might already have two Event nodes in your graph: Start and Update. For more information on these nodes, see [Events node](vs-events-reference.md).
|
||||
|
||||
To add a node to a Script Graph:
|
||||
|
||||
1. [!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]
|
||||
|
||||
2. In the fuzzy finder, enter a search term into the Search bar or select a category from the list to find related nodes.
|
||||
Categories have an arrow (>) at the end of their entry in the fuzzy finder.
|
||||
|
||||
3. Select an entry in the fuzzy finder to add that node to your Script Graph.
|
||||
Visual Scripting adds the node to your Script Graph at the location where you opened the fuzzy finder.
|
||||
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you've added a node to a graph, you can add additional nodes and [connect nodes in a Script Graph](vs-creating-connections.md) to create logic for your application.
|
||||
|
||||
You can also add a [Sticky Note](vs-sticky-notes.md) to add comments to a graph.
|
@ -0,0 +1,31 @@
|
||||
# Add or remove available nodes
|
||||
|
||||
Visual Scripting has a set of default assemblies and generated nodes for Unity features. Add more assemblies through the Visual Scripting Node Library in your Project Settings. Assemblies are special files that contain the code for the feature you want to use.
|
||||
|
||||
Visual Scripting can generate nodes from assemblies in packages and third-party assets. To use a new package or third-party asset in Visual Scripting, you must import it into Unity. For more information on how to add packages to Unity, see [Adding and removing](https://docs.unity3d.com/2021.2/Documentation/Manual/upm-ui-actions.html) in the Unity User Manual. For more information on how to add third-party assets to Unity, see [Importing assets](https://docs.unity3d.com/2021.2/Documentation/Manual/ImportingAssets.html) in the User Manual.
|
||||
|
||||
## Add assemblies and nodes to the Node Library
|
||||
|
||||
To add a new assembly and its nodes to the Node Library:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
1. Expand **Node Library**.
|
||||
1. At the end of the assemblies list, select **Add** (+).
|
||||
1. In the new assembly entry, select **(No Assembly)** to open the **Assembly** menu.
|
||||
1. Select an available assembly from the **Assembly** menu.
|
||||
|
||||
Visual Scripting adds the assembly and its nodes to the Node Library. To use the nodes in your project, [add their types to your Type Options](vs-add-remove-type-options.md#add-a-type-to-your-type-options) and [regenerate the Node Library](vs-configuration.md#Regen).
|
||||
|
||||
## Remove assemblies and nodes from the Node Library
|
||||
|
||||
To remove an assembly and its nodes from your Node Library:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
1. Expand **Node Library**.
|
||||
1. In the assemblies list, locate the entry for the assembly you want to remove.
|
||||
1. Select **Remove** (-).
|
||||
|
||||
Visual Scripting removes the assembly and its nodes from the Node Library. To remove the nodes from the fuzzy finder and your project, [regenerate the Node Library](vs-configuration.md#Regen). You might also want to [remove their types from your Type Options](vs-add-remove-type-options.md#remove-a-type-from-your-type-options).
|
||||
|
@ -0,0 +1,30 @@
|
||||
# Add or remove types
|
||||
|
||||
Type Options specify which node inputs and outputs Visual Scripting supports. After you [add a new assembly](vs-add-remove-node-library.md), you must add types specific to those nodes to your Type Options. Add types to make the nodes and their types accessible in the [fuzzy finder](vs-interface-overview.md#the-fuzzy-finder) and [the Blackboard](vs-interface-overview.md#the-blackboard).
|
||||
|
||||
You can't use a node that has an input or output type that isn't listed in your Type Options.
|
||||
|
||||
## Add a type to your Type Options
|
||||
|
||||
To add a new type to your Type Options list:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
1. Expand **Type Options**.
|
||||
1. At the end of the types list, select **Add** (+).
|
||||
1. In the new type entry, select **(No Type)** to open the **Type** menu.
|
||||
1. Select an available type from the **Type** menu.
|
||||
|
||||
Visual Scripting adds the new type to your Type Options. To use nodes with the type in your project, [regenerate your Node Library](vs-configuration.md#Regen).
|
||||
|
||||
## Remove a type from your Type Options
|
||||
|
||||
To remove a type from your Type Options list:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
1. Expand **Type Options**.
|
||||
1. In the types list, locate the entry for the type you want to remove.
|
||||
1. Select **Remove** (-).
|
||||
|
||||
Visual Scripting removes the type from your Type Options. To make sure that your change appears in your project, [regenerate your Node Library](vs-configuration.md#Regen).
|
@ -0,0 +1,51 @@
|
||||
# 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. [!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]. Go to **Nesting** and select **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.
|
||||
<br/>
|
||||
|
||||
[!include[graph-inspector-tip.md](./snippets/vs-graph-inspector-tip.md)]
|
||||
|
||||
3. If you chose **Graph**, select **New**, enter a name for your graph file, and choose where you want to save it. Select **Save**.
|
||||
|
||||

|
||||
|
||||
## 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. [!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]. Go to **Nesting** and select **Subgraph**.
|
||||
|
||||
2. In the Graph Inspector, set your **Source** to **Graph**.
|
||||
<br/>
|
||||
|
||||
[!include[graph-inspector-tip.md](./snippets/vs-graph-inspector-tip.md)]
|
||||
|
||||
3. In the **Graph** field, select the object picker (circle 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.
|
||||
|
||||

|
||||
|
||||
> [!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
|
||||
|
||||
To open your new Subgraph for editing, select **Edit Graph**.
|
||||
|
||||
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](vs-add-triggers-data-graph.md).
|
||||
|
@ -0,0 +1,31 @@
|
||||
# Add a Trigger or Data port to a Script Graph
|
||||
|
||||
When you use a Script Graph as a Subgraph, you can pass data and logic to it from its parent graph. Add and define ports on your graph to determine which logic and data you can pass to it.
|
||||
|
||||

|
||||
|
||||
To add a Trigger Input, Trigger Output, Data Input, or Data Output port to a Script Graph:
|
||||
|
||||
1. If you haven't already, [open the Script Graph you want to edit in the Graph window](vs-open-graph-edit.md).
|
||||
|
||||
2. With no nodes selected, in the Graph Inspector, select **Add** (+) under the port type you want to add to your Script Graph: **Trigger Inputs**, **Trigger Outputs**, **Data Inputs**, or **Data Outputs**.
|
||||
|
||||
[!include[graph-inspector-tip](./snippets/vs-graph-inspector-tip.md)]
|
||||
|
||||
3. In the **Key** field, enter a unique key name for your port. This name can't be the same as any existing ports on your currently selected Script Graph.
|
||||
|
||||
4. (Optional) In the **Label** field, enter any text you want to appear as a label for the port on a Subgraph, Input, or Output node for your current Script Graph. Otherwise, Visual Scripting uses the value in the **Key** field as a label.
|
||||
|
||||
5. (Optional) In the **Summary** field, enter any text that you want to appear as a brief summary of the port in the Graph Inspector when you select a Subgraph, Input, or Output node for your current Script Graph.
|
||||
|
||||
6. (Optional) Select **Hide Label** to hide the label for the port on any Subgraph, Input, or Output node for your current Script Graph.
|
||||
|
||||
7. (Data Inputs and Data Outputs Only) Select the **Type** list to open the Type menu and select a type for the data your port should accept.
|
||||
|
||||
8. (Data Inputs Only) Select **Has Default Value** to enable the **Default Value** field and specify a default value for your Script Graph's Data Input, if your graph doesn't receive another input while it runs.
|
||||
|
||||
## Next steps
|
||||
|
||||
You can now specify triggers and data for your Script Graph when you use it as a Subgraph in another Script Graph. For more information on each port type, see [Subgraph inputs and outputs](vs-nesting-subgraphs-state-units.md#subgraph-inputs-and-outputs).
|
||||
|
||||
For more information on adding a Script Graph as a Subgraph, see [Add a Subgraph to a Script Graph](vs-add-subgraph.md).
|
@ -0,0 +1,63 @@
|
||||
# Create and add a variable to a Script Graph
|
||||
|
||||
You can create and add a variable to a Script Graph in one of two ways: use the Graph window's Blackboard, or add a node to a graph.
|
||||
|
||||
> [!NOTE]
|
||||
> You can't add a Flow variable to a graph from the Blackboard. For more information on Flow variables, see [Variables](vs-variables.md).
|
||||
|
||||
## Create and add a new variable through the Blackboard
|
||||
|
||||
To create a new variable in the Blackboard and add it to a graph:
|
||||
|
||||
1. With a graph [open in the Graph window](vs-open-graph-edit.md), open [the Blackboard](vs-interface-overview.md#the-blackboard).
|
||||
|
||||
1. In the Blackboard, select the scope for the variable you want to add: **Graph**, **Object**, **Scene**, **App**, or **Saved**.
|
||||
For more information on variable scopes and when you can use each scope in your graph, see [Variables](vs-variables.md).
|
||||
|
||||
3. In the **(New Variable Name)** field, enter a name for the new variable.
|
||||
|
||||
1. Do one of the following:
|
||||
- Press Enter.
|
||||
- Select the **Add Variable** (+) button.
|
||||
|
||||
4. In the **Type** list, select the data type for your variable. For more information on types, see [Object types](vs-types.md).
|
||||
|
||||
5. In the **Value** field, enter or modify the default value for your variable.
|
||||
|
||||
6. To add the node to your graph, click and drag from the Handle (=) on the variable's definition in the Blackboard into the Graph Editor.
|
||||
|
||||
Visual Scripting adds a new Get Variable node for your variable to your graph.
|
||||
|
||||

|
||||
|
||||
|
||||
## Create and add a new variable through the Graph Editor
|
||||
|
||||
To create a Flow variable or another new variable directly in a graph:
|
||||
|
||||
1. [!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]
|
||||
|
||||
2. Select the **Variables** category.
|
||||
|
||||
1. Select the scope for the variable you want to add: **Flow**, **Graph**, **Object**, **Scene**, **Application**, or **Saved**. For more information on variable scopes and when you can use each scope in a graph, see [Variables](vs-variables.md).
|
||||
|
||||
3. Select the **Set `<Scope>` Variable** node, where `<Scope>` is the scope you selected in the previous step.
|
||||
Visual Scripting adds a new Set Variable node to the graph.
|
||||
|
||||
4. In the **Name** field, enter a name for the new variable.
|
||||
|
||||
5. (Object variables only) In the **GameObject** field, indicated by a GameObject icon on the node, specify the GameObject where you want to create the variable. Do one of the following:
|
||||
|
||||
- Select the object picker (circle icon) and select a GameObject.
|
||||
- Attach a node to the field's data input port that outputs a GameObject.
|
||||
- Leave the field as the default value of **This** to use the GameObject where you attached the Script Graph to a Script Machine.
|
||||
|
||||
6. To set a default value for your variable, connect another node that outputs the value you want to the Set Variable node's data input port.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you've added a variable to your graph, you can [add nodes](vs-add-node-to-graph.md), [create node groups](vs-groups.md), or [add a Subgraph](vs-nesting-add-subgraph.md).
|
||||
|
||||
You can also add a [Sticky Note](vs-sticky-notes.md) to add comments to a graph.
|
@ -0,0 +1,18 @@
|
||||
# Advanced customization and development
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
You can customize and extend the basic functionality of Visual Scripting using C# code.
|
||||
|
||||
## Create a Script Graph node
|
||||
|
||||
With a C# script, you can [create your own Custom C# node](vs-create-custom-node.md) and add more functionality to your Visual Scripting graphs.
|
||||
|
||||
## Create a custom event node
|
||||
|
||||
You can trigger logic in your application with [a custom event node](vs-create-own-custom-event-node.md).
|
||||
|
||||
## Add custom types to Visual Scripting
|
||||
|
||||
Add your own [custom classes and types in Visual Scripting](vs-custom-types.md) to store information more efficiently.
|
@ -0,0 +1,23 @@
|
||||
# Use Visual Scripting with Unity Cloud Build
|
||||
|
||||
At build time, Unity removes any code that isn't used by a project to reduce build size. This can cause problems with Visual Scripting because Unity can remove code that's necessary for Script Graphs to run in a project.
|
||||
|
||||
For versions 1.7.x, Visual Scripting generates an `AotStubs.cs` file, which stores the Unity APIs that graphs use. With the `AotStubs.cs` file, Unity doesn't remove any Unity APIs used in a graph from a build. You can generate this file when you create a build of a project.
|
||||
|
||||
Builds through Unity Cloud Build can fail because Cloud Build prevents domain reload between the prebuild and build phases of the project. Without a domain reload, the build doesn't include the generated `AotStubs.cs` file. For more information about domain reload, see [Domain Reloading](https://docs.unity3d.com/Manual/DomainReloading.html) in the Unity User Manual.
|
||||
|
||||
To build a Visual Scripting project with Cloud Build, do the following:
|
||||
|
||||
1. Build the project locally for your desired platform. <br/>For more information on how to build a project, see the relevant section for each platform in [Platform development](https://docs.unity3d.com/Documentation/Manual/PlatformSpecific.html) in the User Manual.
|
||||
|
||||
2. After the build, do one of the following:
|
||||
- Open the project files in the system file explorer.
|
||||
- Open the [Project window](https://docs.unity3d.com/Manual/ProjectView.html) in the Unity Editor.
|
||||
|
||||
3. In the project files, go to **Assets** > **Unity.VisualScripting.Generated** > **VisualScripting.Core**.
|
||||
|
||||
4. Locate the `AotStubs.cs` file.
|
||||
|
||||
5. Add the `AotStubs.cs` file to your source control system.
|
||||
|
||||
Your Cloud Build settings might automatically trigger a new build of the project after you commit the `AotStubs.cs` file. For more information about version control systems and Cloud Build, see [Unity Cloud Build](https://docs.unity3d.com/Manual/UnityCloudBuild.html) in the User Manual.
|
@ -0,0 +1,41 @@
|
||||
# Attach a graph file to a Script Machine or State Machine
|
||||
|
||||
To use a Script Graph or State Graph file in your project, you must attach it to a Script Machine or State Machine.
|
||||
|
||||
A Script Machine or State Machine is a component. Components attach to GameObjects, and help define their behavior. For more information on components and GameObjects, see [Using components](https://docs.unity3d.com/2021.1/Documentation/Manual/UsingComponents.html) or [GameObjects](https://docs.unity3d.com/2021.1/Documentation/Manual/GameObjects.html) in the Unity User Manual.
|
||||
|
||||
## Add a Script Machine or State Machine component to a GameObject
|
||||
|
||||
1. [!include[open-hierarchy](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select a GameObject where you'd like to add a Script Machine or State Machine.
|
||||
|
||||
2. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
3. In the GameObject's Inspector window, select **Add Component**.
|
||||
|
||||
The Components menu opens.
|
||||
|
||||
4. Do one of the following:
|
||||
- To add a Script Machine or State Machine, in the Components menu, go to **Visual Scripting** and select **Script Machine** or **State Machine**.
|
||||
- Use the search bar to find the Script Machine or State Machine component.
|
||||
|
||||
The new Script Machine or State Machine component appears in the Inspector window for the GameObject:
|
||||
|
||||

|
||||
|
||||
## Attach a graph file to the Script Machine or State Machine
|
||||
|
||||
1. In the Inspector window, locate your Script Machine or State Machine component.
|
||||
|
||||
1. Set the **Source** to **Graph**.
|
||||
|
||||
2. Do one of the following:
|
||||
- In the **Graph** field, select the object picker (circle icon) and choose a compatible graph file from your project.
|
||||
- Click and drag a file from your Project window and drop it into the **Graph** field.
|
||||
|
||||
For more information on how to create Script or State Graphs, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
## Next steps
|
||||
|
||||
After you attach a graph to a Script Machine or State Machine, you can open the graph and edit. For more information, see [Open a graph file](vs-open-graph-edit.md).
|
@ -0,0 +1,31 @@
|
||||
# Basic concepts in Visual Scripting
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
In this section, you can find information about basic concepts in Visual Scripting. These concepts will help you create logic for your application.
|
||||
|
||||
## The interface
|
||||
|
||||
The Visual Scripting interface starts with the Graph window. For more information, see [The interface](vs-interface-overview.md).
|
||||
|
||||
## Nodes
|
||||
|
||||
Nodes are the most basic part of creating scripts in Visual Scripting. For more information, see [Nodes](vs-nodes.md).
|
||||
|
||||
## Graphs and Machines
|
||||
|
||||
Graphs contain the visual representations of logic in your application. To use a graph, you attach it to a Script Machine or State Machine on a GameObject. For more information about graphs, see [Graphs](vs-graph-types.md). For more information about Script Machines and State Machines, see [Script Machines and State Machines](vs-graph-machine-types.md).
|
||||
|
||||
## Variables
|
||||
|
||||
Variables act as a container for a piece of information that might change as your application runs. For more information, see [Variables](vs-variables.md).
|
||||
|
||||
## Object types
|
||||
|
||||
Variables, data, and objects in Visual Scripting all have a specific type. For more information, see [Object types](vs-types.md).
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
# Add and configure a Player Input component
|
||||
|
||||
To use the Input System package with Visual Scripting, add a Player Input component to the same GameObject as the Script Graph and create an Input Actions asset.
|
||||
|
||||
You must add the Player Input component and create the Input Actions asset before you create the Script Graph.
|
||||
|
||||
> [!NOTE]
|
||||
> If the Input System package isn't installed in your project, follow the Input System documentation's [Installation guide](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/Installation.html) to install the package. Go to **Window** > **Package Manager** to check your installed packages.
|
||||
|
||||
To add a Player Input component to a GameObject:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
2. In the Hierarchy window, select the GameObject that you want to move with the Script Graph.
|
||||
|
||||
3. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
4. Select **Add Component**.
|
||||
The Components menu opens.
|
||||
|
||||
5. In the Components menu, do one of the following:
|
||||
- Go to **Input**.
|
||||
- In the Search bar, enter `Player Input`.
|
||||
|
||||
6. Select the **Player Input** component to add it to the GameObject.
|
||||
|
||||
1. Add an Input Actions asset to the Player Input component. Do one of the following:
|
||||
- [Create a new Input Actions asset](#create-a-new-input-actions-asset).
|
||||
- [Use an existing Input Actions asset](#use-an-existing-input-actions-asset).
|
||||
|
||||

|
||||
## Create a new Input Actions asset
|
||||
|
||||
1. Select **Create Actions**.
|
||||
|
||||
1. Choose a location in your project to save the Input Actions asset.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||
## Use an existing Input Actions asset
|
||||
|
||||
1. Do one of the following:
|
||||
- Click the **Actions** field's object picker (circle icon) and in the **SelectInputActionAsset** window, select the asset.
|
||||
- Click and drag a file from your Project window and drop it into the **Actions** field.
|
||||
|
||||
## Next steps
|
||||
|
||||
To configure the available options on a Player Input component, see [GameObject components for input](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/Components.html) in the Input System package documentation.
|
||||
|
||||
To configure an Input Actions asset, see [Input Action Assets](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/ActionAssets.html) in the Input System package documentation.
|
||||
|
||||
To create a simple Script Graph to capture input with Visual Scripting, see [Capture input with the Input System package](vs-capturing-player-inputs-new.md).
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Capture user input in an application](vs-capture-player-input.md)
|
||||
- [Capture input with the Input System package](vs-capturing-player-inputs-new.md)
|
||||
- [Input event nodes](vs-input-nodes.md)
|
@ -0,0 +1,54 @@
|
||||
# Capture user input in an application
|
||||
|
||||
You can capture input from a user's input device to make your application interactive. Visual Scripting can use either the [Input Manager](https://docs.unity3d.com/Manual/class-InputManager.html) or the [Input System package](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest) to capture input data in a Script Graph.
|
||||
|
||||
## Use the Input System package
|
||||
|
||||
The Input System package captures input in Unity applications. It uses any input device and replaces Unity's [Input Manager](#use-the-input-manager).
|
||||
|
||||
To install the Input System package, see the [Installation guide](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/Installation.html) in the Input System package documentation.
|
||||
|
||||
To check if the Input System package is installed, go to **Window** > **Package Manager**.
|
||||
|
||||

|
||||
|
||||
For more information on the Package Manager and managing packages in projects, see the [Packages](https://docs.unity3d.com/Manual/PackagesList.html) section in the Unity User Manual.
|
||||
|
||||
### Input System package prerequisites
|
||||
|
||||
To use the Input System package in a project, do the following:
|
||||
|
||||
1. Install the package. For more information, see the [Packages](https://docs.unity3d.com/Manual/PackagesList.html) section in the User Manual.
|
||||
|
||||
2. Regenerate your Node Library to include the Input System package nodes. For more information, [Configure project settings](vs-configuration.md#Regen).
|
||||
|
||||
3. In your Player Project Settings, set **Active Input Handling** to **Input System Package (New)** or **Both**. For more information on this setting, see [Standalone Player settings](https://docs.unity3d.com/Manual/class-PlayerSettingsStandalone.html#Configuration) in the User Manual.
|
||||
|
||||
4. Create an Input System settings asset. Go to **Edit** > **Project Settings** and select **Input System Package**, then select **Create Settings Asset**. For more information on the available input settings, see [Input Settings](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/Settings.html) in the Input System package documentation.
|
||||
|
||||
5. Create a GameObject with a `PlayerInput` component and an Input Actions asset. For more information, see [Add and configure a PlayerInput component](vs-capture-player-input-add-component.md).
|
||||
|
||||
After you've configured your project, create a graph to [Capture input with the Input System package](vs-capturing-player-inputs-new.md).
|
||||
|
||||
## Use the Input Manager
|
||||
|
||||
The Input Manager is Unity's built-in system for input.
|
||||
|
||||
Change the Input Manager's settings to change how a project receives input. Go to **Edit** > **Project Settings** and select **Input Manager**.
|
||||
|
||||

|
||||
|
||||
For more information on the available settings, see the [Input Manager documentation](https://docs.unity3d.com/Documentation/Manual/class-InputManager.html) in the User Manual.
|
||||
|
||||
### Input Manager prerequisites
|
||||
|
||||
To use the Input Manager in a project, in your Player Project Settings, set **Active Input Handling** to **Input Manager (Old)** or **Both**. For more information on this setting, see [Standalone Player settings](https://docs.unity3d.com/Manual/class-PlayerSettingsStandalone.html#Configuration) in the User Manual.
|
||||
|
||||
After you’ve configured your Player Project Settings, create a graph to [Capture input with the Input Manager](vs-capturing-player-inputs-old.md).
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Add and configure a Player Input component](vs-capture-player-input-add-component.md)
|
||||
- [Capture input with the Input System package](vs-capturing-player-inputs-new.md)
|
||||
- [Capture input with the Input Manager](vs-capturing-player-inputs-old.md)
|
||||
- [Input event nodes](vs-input-nodes.md)
|
@ -0,0 +1,85 @@
|
||||
# Capture input with the Input System package
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If you don't complete the prerequisite configuration for your project, you can't use the Input System package with Visual Scripting. For more information, see [Input System package prerequisites](vs-capture-player-input.md#input-system-package-prerequisites).
|
||||
|
||||
To use the Input System package with Visual Scripting to capture input in your project:
|
||||
|
||||
1. [Open](vs-open-graph-edit.md) or [create](vs-create-graph.md) a Script Graph attached to the GameObject that you want your users to move.
|
||||
|
||||
2. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]
|
||||
|
||||
3. Go to **Events** > **Input** or search for **On Input System Event**.
|
||||
|
||||
4. Select an Input System Event node. In this example, select the **On Input System Event Vector 2** node to add it to the graph.
|
||||
|
||||
5. Set the **On Input System Event Vector 2** node's **Input Action Change Type** control to **On Hold**:
|
||||
|
||||

|
||||
|
||||
6. In the **Input Action** list on the **On Input System Event Vector 2** node, select an Input Action to trigger the node. In this example, select **Move**.
|
||||
|
||||
> [!NOTE]
|
||||
> By default, Visual Scripting displays all Input Actions from the Input Action asset attached to your current GameObject's Player Input component.
|
||||
|
||||
7. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]
|
||||
|
||||
> [!TIP]
|
||||
> If a context menu appears when you right-click, select **Add Node** to open the fuzzy finder.
|
||||
|
||||
8. Go to **Codebase** > **Unity Engine** > **Vector 3** or search for **Vector 3 Get X**.
|
||||
|
||||
9. Select **Get X** to add the **Vector 3 Get X** node to the graph.
|
||||
|
||||
10. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]
|
||||
|
||||
11. Go to **Codebase** > **Unity Engine** > **Vector 3** or search for **Vector 3 Get Z**.
|
||||
|
||||
12. Select **Get Z** to add the **Vector 3 Get Z** node to the graph.
|
||||
|
||||
13. Select the **Vector 2 Value** output port on the **On Input System Event Vector 2** node.
|
||||
|
||||
14. [Make a connection](vs-creating-connections.md) to the **Target** input port on the **Vector 3 Get X** node:
|
||||
|
||||

|
||||
|
||||
15. Select the **Vector 2 Value** output port.
|
||||
|
||||
16. [Make a connection](vs-creating-connections.md) to the **Target** port on the **Vector 3 Get Z** node.
|
||||
|
||||
17. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]
|
||||
|
||||
18. Go to **Codebase** > **Unity Engine** > **Transform** or search for **Translate**.
|
||||
|
||||
19. Select **Transform: Translate (X, Y, Z)** to add the Translate node to the graph.
|
||||
|
||||
20. Select the **Value: Float** output port on the **Vector 3 Get X** node.
|
||||
|
||||
21. [Make a connection](vs-creating-connections.md) to the **X** float input port on the **Translate** node.
|
||||
|
||||
22. Select the **Value: Float** output port on the **Vector 3 Get X** node.
|
||||
|
||||
23. [Make a connection](vs-creating-connections.md) to the **Z** float input port on the **Translate** node.
|
||||
|
||||
The finished graph looks similar to the following image:
|
||||
|
||||

|
||||
|
||||
24. To enter Play mode, select **Play** from [the Unity Editor's Toolbar](https://docs.unity3d.com/Manual/Toolbar.html).
|
||||
|
||||
25. While in the [Game view](https://docs.unity3d.com/Manual/GameView.html), press a key defined under the Input Actions asset for **Move** in the **Player** Action Map.
|
||||
|
||||
|
||||
The GameObject moves along the X or Z axis in the Game view, based on the key pressed and the Input Actions asset.
|
||||
|
||||
For more information on how to define Input Actions, see [Input Action Assets](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/ActionAssets.html) in the Input System package documentation.
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Capture user input in an application](vs-capture-player-input.md)
|
||||
- [Add and configure a Player Input component](vs-capture-player-input-add-component.md)
|
||||
- [On Input System Event Button node](vs-nodes-events-input-system-button.md)
|
||||
- [On Input System Event Float node](vs-nodes-events-input-system-float.md)
|
||||
- [On Input System Event Vector 2 node](vs-nodes-events-input-system-vector2.md)
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
# Capture input with the Input Manager
|
||||
|
||||
> [!NOTE]
|
||||
> You must configure your Project Settings to use the Input Manager with Visual Scripting. For more information, see [Input Manager prerequisites](vs-capture-player-input.md#input-manager-prerequisites).
|
||||
|
||||
To create a basic Script Graph that uses the Input Manager to capture input:
|
||||
|
||||
<ol>
|
||||
<li><p><a href="vs-open-graph-edit.md">Open</a> or <a href="vs-create-graph.md">create</a> a Script Graph attached to the GameObject that you want your users to move.</p></li>
|
||||
<li><p>If there isn't an <strong>On Update</strong> or similar Event node in your graph:</p>
|
||||
<ol type="a">
|
||||
<li><p>[!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]</p></li>
|
||||
<li><p>Go to <strong>Events</strong> > <strong>Lifecycle</strong>, or enter <strong>On Update</strong> in the search field.</p></li>
|
||||
<li><p>Select the <strong>On Update</strong> Event node to add it to the graph.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><p>[!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]</p></li>
|
||||
<div class="TIP"><h5>TIP</h5><p>If you right-click and the context menu appears, select <strong>Add Node</strong> to open the fuzzy finder.</p></div>
|
||||
<li><p>Go to <strong>Codebase</strong> > <strong>Unity Engine</strong> > <strong>Input</strong>, or enter <strong>Get Axis</strong> in the search field.</p></li>
|
||||
<li><p>Select <strong>Get Axis (Axis Name)</strong> to add the Get Axis node to the graph.</p></li>
|
||||
<li><p>Repeat Steps 3 through 5 to create a second <strong>Get Axis (Axis Name)</strong> node.</p></li>
|
||||
<li><p>On the first Get Axis node, in the <strong>Axis Name</strong> input field, enter <code>Horizontal</code>.</p></li>
|
||||
<li><p>On the second Get Axis node, in the <strong>Axis Name</strong> input field, enter <code>Vertical</code>.</p></li>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>If an Axis Name doesn't match the name in the Input Manager's Project Settings, Visual Scripting displays an error in the Graph Inspector. When you enter Play mode, the Unity Editor also displays an error in the Console window.</p></div>
|
||||
<li><p>[!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]</p></li>
|
||||
<li><p>Go to <strong>Codebase</strong> > <strong>Unity Engine</strong> > <strong>Transform</strong> or search for <strong>Translate</strong>.</p></li>
|
||||
<li><p>Select <strong>Translate (X, Y, Z)</strong> to add a Translate node to the graph.</p></li>
|
||||
<li><p>Select the <strong>Result</strong> float output port on the <code>Horizontal</code> Get Axis node.</p></li>
|
||||
<li><p><a href="vs-creating-connections.md">Make a connection</a> to the <strong>X</strong> input port on the <strong>Translate</strong> node.</p></li>
|
||||
<li><p>Select the <strong>Result</strong> float output port on the <code>Vertical</code> Get Axis node.</p></li>
|
||||
<li><p><a href="vs-creating-connections.md">Make a connection</a> to the <strong>Z</strong> input port on the <strong>Translate</strong> node. <br/>The finished graph looks similar to the following image:</p></li>
|
||||
<p><img src="images/vs-input-old-system-example.png" alt="An image of the Graph window, that displays the final result of a simple input capture graph using the Input Manager. An On Update node connects to the Trigger input port on a Transform Translate node. The Result port on an Input Get Axis node with an Axis Name of Horizontal connects to the X input port on the Translate node. The Result port on another Input Get Axis node with an Axis Name of Vertical connects to the Z input port."></p>
|
||||
<li><p>To enter Play mode, select <strong>Play</strong> from the <a href="https://docs.unity3d.com/Manual/Toolbar.html">Unity Editor's Toolbar</a>.</p></li>
|
||||
<li><p>While in the <a href="https://docs.unity3d.com/Manual/GameView.html">Game view</a>, press a key mapped as a <strong>Negative Button</strong> or <strong>Positive Button</strong> from the <a href="https://docs.unity3d.com/Documentation/Manual/class-InputManager.html">Input Manager's virtual axes</a>.</p></li>
|
||||
</ol>
|
||||
|
||||
The GameObject moves along the X or Z axis in the Game view, based on the key pressed and the [Input Manager Project Settings](https://docs.unity3d.com/Documentation/Manual/class-InputManager.html).
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Capture user input in an application](vs-capture-player-input.md)
|
||||
- [Capture input with the Input System package](vs-capturing-player-inputs-new.md)
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
|
@ -0,0 +1,70 @@
|
||||
# Configure project settings
|
||||
|
||||
> [!NOTE]
|
||||
> To use Visual Scripting in a project for the first time, you must [initialize it](#Initialize) from the Editor's [Project Settings](https://docs.unity3d.com/Manual/comp-ManagerGroup.html) window.
|
||||
|
||||
Use the Project Settings window with Visual Scripting to manage backups, node assemblies, type options, and regenerate your Node Library.
|
||||
|
||||
To open your Project Settings:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
|
||||
You can find the following configuration options in your Visual Scripting Project Settings. To use Visual Scripting in a project for the first time, you must [regenerate your Node Library](#Regen), as described in the table below.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Option</strong></th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong><a name="Initialize">Initialize Visual Scripting</a></strong></td>
|
||||
<td>You must select <strong>Initialize Visual Scripting</strong> the first time you use Visual Scripting in a project. Initialize Visual Scripting to parse all assemblies and types for the Visual Scripting Node Library. After you initialize Visual Scripting, regenerate your Node Library. See <strong><a href="#Regen">Regenerate Nodes</a></strong>, below.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Type Options</strong></td>
|
||||
<td>Use the Type Options list to add or remove types for your node inputs and outputs. After you add or remove a type, you must regenerate your Node Library. See <strong><a href="#Regen">Regenerate Nodes</a></strong>, below. <br/>For more information on how to add or remove types, see <a href="vs-add-remove-type-options.md">Add or remove types</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Node Library</strong></td>
|
||||
<td>Use the Node Library list to add or remove nodes and their assemblies in Visual Scripting. You must add any new types to your Type Options after you add new nodes to Visual Scripting. You must also regenerate your Node Library after you add or remove nodes. See <a href="#Regen"><strong>Regenerate Nodes</strong></a>, below. <br/>For more information on how to add or remove nodes from your Node Library, see <a href="vs-add-remove-node-library.md">Add or remove available nodes</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><a name="Regen">Regenerate Nodes</a></strong></td>
|
||||
<td>Regenerate your Node Library to make all nodes available for use in a project. <br/>To use Visual Scripting for the first time in a project, you must <strong><a href="#Initialize">Initialize Visual Scripting</a></strong> and regenerate your Node Library. <br/>To regenerate your Node Library:
|
||||
<ol>
|
||||
<li><p>Select <strong>Regenerate Nodes</strong>.</p></li>
|
||||
<li><p>Select <strong>OK</strong>.</p></li>
|
||||
</ol>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>You must regenerate your Node Library in the following circumstances:
|
||||
<ul>
|
||||
<li>Before you use Visual Scripting in your project for the first time.</li>
|
||||
<li>After you add or remove nodes from your Node Library.</li>
|
||||
<li>After you add or remove types from your Type Options.</li>
|
||||
<li>After you change the inputs or outputs for a Custom C# node.</li>
|
||||
</ul></p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Generate</strong></td>
|
||||
<td>To generate required property provider scripts for custom drawers, select <strong>Generate</strong>. <br/>These scripts are necessary for Unity to use custom drawers for custom classes and script variables inside Visual Scripting. To assign a default value to a custom variable type through the Unity Editor’s Inspector, you must either have access to the source code for the class, or provide a custom PropertyDrawer. For more information, see <a href="vs-custom-types.md">Custom types</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Create Backup</strong></td>
|
||||
<td>To create a new backup of your Visual Scripting graphs and settings, select <strong>Create Backup</strong>. <br/> For more information about backups, see <a href="vs-create-restore-backups.md">Create or restore a backup</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Restore Backup</strong></td>
|
||||
<td>To open the folder where Visual Scripting stores your backups, select <strong>Restore Backup</strong>. <br/>For more information about backups, see <a href="vs-create-restore-backups.md">Create or restore a backup</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Fix Missing Scripts</strong></td>
|
||||
<td>To correct any issues that might occur after migration from the Unity Asset Store version of Visual Scripting to the package version, select <strong>Fix Missing Scripts</strong>. This resolves any missing references to Visual Scripting Script Graphs and State Graphs in Script Machine or State Machine components.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
>[!NOTE]
|
||||
> If your settings don't apply after you make a change, [report a bug through the Unity Editor](https://unity3d.com/unity/qa/bug-reporting).
|
@ -0,0 +1,109 @@
|
||||
# Choose a control scheme
|
||||
|
||||
You can choose from two different control schemes in Visual Scripting. Each control scheme changes how you can interact with your graphs in the Graph Editor:
|
||||
|
||||
|**Action** |**Default Control Scheme** |**Alternate Control Scheme** |
|
||||
|:---|:---|:---|
|
||||
|[**Pan**](#pan)| Middle-click and drag | Middle-click and drag |
|
||||
|[**Pan Vertically**](#pan-vertically) | Scroll | N/A |
|
||||
|[**Zoom In/Zoom Out**](#zoom-inzoom-out) | Ctrl+Scroll (macOS: Cmd+Scroll) | Scroll |
|
||||
|[**Frame Selected**](#frame-selected) | Home | Home |
|
||||
|[**Frame All**](#frame-all) | Home | Home |
|
||||
|[**Create Selection**](#create-selection) | Click and drag | Click and drag |
|
||||
|[**Select All**](#select-all) | Ctrl+A (macOS: Cmd+A)| Ctrl+A (macOS: Cmd+A) |
|
||||
|[**Open Context Menu**](#open-context-menu)| Right-click <br/>Ctrl+click (macOS) <br/>Ctrl+E (macOS: Cmd+E) | Right-click <br/>Ctrl + click (MacOS) <br/>Ctrl+E (macOS: Cmd+E) |
|
||||
|[**Create Node Group**](#create-node-group)| Ctrl+click and drag (macOS: Cmd+click and drag) | Ctrl+click and drag (macOS: Cmd+click and drag) |
|
||||
|[**Copy Selected**](#copy-selected)| Ctrl+C (macOS: Cmd+C) | Ctrl+C (macOS: Cmd+C) |
|
||||
|[**Paste Selection**](#paste-selection)| Ctrl+V (macOS: Cmd+V) | Ctrl+V (macOS: Cmd+V) |
|
||||
|[**Cut Selected**](#cut-selected)| Ctrl+X (macOS: Cmd+X) | Ctrl+X (macOS: Cmd+X) |
|
||||
|[**Duplicate Selected**](#duplicate-selected)| Ctrl+D (macOS: Cmd+D)| Ctrl+D (macOS: Cmd+D) |
|
||||
|[**Delete Selected**](#delete-selected)| Del | Del |
|
||||
|[**Maximize Graph Window**](#maximize-graph-window)| Shift+Space <br/>Double-click | Shift+Space <br/>Double-click |
|
||||
|[**Move Group Without Child Nodes**](#move-group-without-child-nodes)| Alt+click and drag the group's Title bar | Ctrl+click and drag the group's Title bar (macOS: Cmd+click and drag)|
|
||||
|[**Move Node on One Axis**](#move-node-on-one-axis)| Shift+click and drag vertically or horizontally | Shift+click and drag vertically or horizontally |
|
||||
|
||||
|
||||
## Pan
|
||||
|
||||
Pan to move the viewable area in the Graph Editor to any part of your graph.
|
||||
|
||||
## Pan Vertically
|
||||
|
||||
With the **Default** control scheme, pan the view in the Graph Editor vertically with the scroll wheel on your mouse.
|
||||
|
||||
## Zoom In/Zoom Out
|
||||
|
||||
Change the zoom level in the Graph window to control how much of your graph is visible in the Graph Editor.
|
||||
|
||||
You can also set your zoom level with the toolbar in the Graph window. For more information, see [The interface](vs-interface-overview.md#the-graph-toolbar).
|
||||
|
||||
## Frame Selected
|
||||
|
||||
After you select a node or another item in your graph, press Home to center your selected item in the Graph Editor.
|
||||
|
||||

|
||||
|
||||
## Frame All
|
||||
|
||||
With no nodes or items selected, press Home to center your entire graph in the Graph Editor. Your zoom level automatically adjusts to accommodate the size of your graph.
|
||||
|
||||

|
||||
|
||||
## Create Selection
|
||||
|
||||
Click and drag to create a selection box around any nodes or items in your graph that you want to select.
|
||||
|
||||

|
||||
|
||||
When you have multiple items selected, click and drag a single item to move the entire selection.
|
||||
|
||||
## Select All
|
||||
|
||||
Press Ctrl+A (macOS: Cmd+A) to select all items in your current graph.
|
||||
|
||||
## Open Context Menu
|
||||
|
||||
You can open the context menu to perform certain actions on State Graphs or manipulate a selection in a Script Graph. You can create new states and add transitions.
|
||||
|
||||

|
||||
|
||||
## Create Node Group
|
||||
|
||||
Create a group of nodes to keep related sections of your graph together, or move multiple nodes at a time. For more information on node groups, see [Create node groups](vs-groups.md).
|
||||
|
||||

|
||||
|
||||
## Copy Selected
|
||||
|
||||
Copy your current selection to move it to another graph, or another location on your current graph.
|
||||
|
||||
## Paste Selection
|
||||
|
||||
Paste the contents of a copied or cut selection into your graph.
|
||||
## Cut Selected
|
||||
|
||||
Cut your current selection to move it to another graph, or another location on your current graph.
|
||||
|
||||
## Duplicate Selected
|
||||
|
||||
Duplicate a selection to instantly create a copy of your current selection to use elsewhere in your current graph.
|
||||
|
||||

|
||||
|
||||
## Delete Selected
|
||||
|
||||
Delete your current selection to remove it from your graph.
|
||||
|
||||
## Maximize Graph Window
|
||||
|
||||
After you dock the Graph window in the Unity Editor, press Shift+Space or double-click maximize your Graph window and take up the entire Editor window.
|
||||
|
||||
## Move Group Without Child Nodes
|
||||
|
||||
You can move a group in your graph without any of the nodes contained inside that group.
|
||||
|
||||

|
||||
|
||||
## Move Node on One Axis
|
||||
|
||||
Shift+click to move a node in only one direction at a time in the Graph Editor. The node can move either vertically or horizontally.
|
@ -0,0 +1,190 @@
|
||||
# Control nodes
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Control nodes branch, loop and merge the flow.
|
||||
|
||||
## Branching
|
||||
|
||||
Branching nodes split the control flow based on a value.
|
||||
|
||||
### If
|
||||
The common if node uses a boolean condition. Consider them as an "if the condition is true, do something, otherwise, do something else."
|
||||
|
||||

|
||||
|
||||
### Switch
|
||||
|
||||
Branch on the value of an enum, a string, or an integer. These nodes are called Switch nodes.
|
||||
|
||||
To switch on an enum, decide on the type of the enum. The branch output ports appears.
|
||||
|
||||

|
||||
|
||||
To switch on a string or number, create each branch option in the graph inspector.
|
||||
|
||||

|
||||
|
||||
The node is updated with each output port.
|
||||
|
||||
For strings, optionally choose to ignore the case of the selector.
|
||||
|
||||
> [!NOTE]
|
||||
> A Default port is always added. It is the path that the control flow should take if the input selector does not correspond to any other option.
|
||||
|
||||
### Select
|
||||
|
||||
Select nodes are the opposite of switch nodes. You can select a single value from a set of options based on a selector.
|
||||
|
||||
For example, a Select On Integer node that chooses a color based on a player number.
|
||||
|
||||
|
||||

|
||||
|
||||
>[!NOTE]
|
||||
> In the above example predictive debugging warns of a crash if playerNo is not within 1, 2, 3, or 4, because the Default port is not connected.
|
||||
|
||||
## Looping
|
||||
|
||||
Loops repeats logic for a certain number of iterations before moving on.
|
||||
|
||||
The logic to be repeated is called the body of the loop. After the loop is over, the exit port is called.
|
||||
|
||||
>[!NOTE]
|
||||
> The body of every loop is called synchronously, not over the course of multiple frames. Co-routine-like behaviours are achieved by listening to the update event manually.
|
||||
|
||||
### While Loop
|
||||
|
||||
The while loop is the simplest form of loop. It repeats its body while its condition remains true. Only when the condition becomes false does the loop terminate.
|
||||
|
||||
For example, the following graph generates a new random name until the result isn't contained in the names application variable.
|
||||
|
||||

|
||||
|
||||
> [!WARNING]
|
||||
> Do not create an infinite loop. If the condition is always true, the editor hangs. As loop bodies are synchronous, not parallel, there are few uses for while loops in visual scripting.
|
||||
|
||||
### For Each Loop
|
||||
|
||||
For Each iterates over every element of a collection. It outputs the current index and item that is being looped over.
|
||||
|
||||
For example, the following graph outputs three messages to the console:
|
||||
|
||||
* *I like cats*
|
||||
* *I like dogs*
|
||||
* *I like birds*
|
||||
|
||||

|
||||
|
||||
To access the key and value from dictionaries in the loop, check the Dictionary box.
|
||||
|
||||
### For Loop
|
||||
|
||||
For is a numeric loop and requires three integers: a start index, an end index, and a step. The loop starts at the first index, then increments towards the last index via increments of the step. It outputs the current index.
|
||||
|
||||
For example, this graph counts to ten by skipping odd numbers because of its step. In other words, its output is 0, 2, 4, 6, then 8.
|
||||
|
||||

|
||||
|
||||
The for loop can also be very useful when combined to the Get List Item and Count Items nodes.
|
||||
|
||||
For example, the folllowing graph is very similar to the last graph as the output to the console is "I like {animal}s".
|
||||
|
||||
Instead of using the for each node that outputs each item, the graph outputs each item manually by its index in the list. This specifies a different increment (in this case 2) and skips some items. This graph outputs two messages:
|
||||
|
||||
* *I like cats*
|
||||
* *I like birds*
|
||||
|
||||

|
||||
|
||||
### Break Loop
|
||||
|
||||
A loop can finish early by using the Break Loop node. As soon as this node is entered, the exit port of the loop is called, no matter how many more iterations remain.
|
||||
|
||||
For example, even though this for loop is supposed to count to 10, it stops at 5 because of the break. Its output is 0, 1, 2, 3, then 4.
|
||||
|
||||

|
||||
|
||||
## Exception Handling
|
||||
|
||||
### Try Catch
|
||||
|
||||
The Try Catch node handles [Exceptions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/) that occur. It prevents your game from crashing in case you suspect some code might fail.
|
||||
|
||||
Anything that gets executed in the Try branch is considered "safe": the script continues from the Catch branch instead if it fails. The Exception port captures information about the failure when that happens. A common way of handling this is to log a warning with the exception message.
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> By default, this node catches all exceptions. Be specific in your handling by changing the exception type in the dropdown.
|
||||
|
||||
The Finally branch is optional. It is always called after Try or Catch, regardless of whether the operation succeeded or not. It is usually used to dispose or destroy any resources that must be freed. This port can be disconnected if there is no need to destroy any resources.
|
||||
|
||||
### Throw
|
||||
|
||||
The Throw node allows you to raise your own exceptions that stop the flow. These are caught with Try Catch.
|
||||
|
||||
It is good practice to "fail early" by throwing as soon as something unexpected happens. It helps catch bugs early in the chain, instead of letting them trickle down and have unexpected side effects that are hard to debug.
|
||||
|
||||
For example, to ensure damage is positive before applying it:
|
||||
|
||||

|
||||
|
||||
If the Custom checkbox is selected, you can pass a custom Exception object that contains more data than a simple message. Most often, this is not required. By default, the thrown exception is of type `System.Exception`.
|
||||
|
||||
## Toggles
|
||||
|
||||
Toggle nodes are similar in principle to light-switches: they can be turned on and off to impact either the script or values. Think of them as "gates" that can be opened and closed.
|
||||
|
||||
### Toggle Flow
|
||||
|
||||
The Toggle Flow node gates the flow of control. When on, the flow passes through; when off, the flow does not.
|
||||
|
||||
There are many inputs and outputs that allow fine grain control over the logic. In the previous example, Toggle is used to show the same event (a keypress) turns the toggle on and off. This can be done by using On and Off through two different events.
|
||||
|
||||
There are many inputs and outputs that allow fine grain control over the logic. In a previous example, Toggle is used to show the same event (a keypress) turns the toggle on and off; for the same results using two different events, use On and Off instead.
|
||||
|
||||
On the output side, the Is On boolean port indicates the toggle status, that is turned on or off. The control outputs are triggered according to the table below:
|
||||
|
||||
| Port | Triggered When |
|
||||
|---|---|
|
||||
| On| Flow enters the toggle via the unmarked input while it is on.|
|
||||
| Off| Flow enters the toggle via the unmarked input while it is off.|
|
||||
| Turned On | The toggle gets turned on, either via the On or Toggle inputs. |
|
||||
| Turned Off | The toggle gets turned off, either via the Off or Toggle inputs. |
|
||||
|
||||
### Toggle Value
|
||||
|
||||
The Toggle Value node selects between two different input values depending on whether it is on or off. Its ports work exactly like the Toggle Flow node.
|
||||
|
||||
Another way of implementing the same logic as the previous example: clicking Space toggles the object to move up. This time a value of 1 or 0 is provided as the vertical velocity.
|
||||
|
||||
> [!NOTE]
|
||||
> Turn on relations in the toolbar as a means to visualize the flow between the toggle ports.
|
||||
|
||||

|
||||
|
||||
## Once
|
||||
|
||||
The Once node executes different logic the first time it is traversed from any subsequent times.
|
||||
|
||||

|
||||
|
||||
It can be reset by entering the Reset port.
|
||||
|
||||
## Cache
|
||||
|
||||
The Cache node saves the result of an expensive operating and reuses it instead of fetching it again each time you need it.
|
||||
|
||||
For example, using this graph, the formula is calculated twice:
|
||||
|
||||

|
||||
|
||||
By using the Cache node, the result is saved and calculated only once, optimizing performance.
|
||||
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> It is important to note that caching only lasts within the scope of the current flow. The value of the cache is not shared or available from another event.
|
@ -0,0 +1,76 @@
|
||||
# Create a custom PropertyDrawer for a custom type
|
||||
|
||||
If you want to use a custom type from a custom class in Visual Scripting, and you don't have access to its source code, you must create a custom PropertyDrawer.
|
||||
|
||||
You can't assign a value to a custom type inside the Editor or initialize the value for a variable with a custom type if it doesn't have a PropertyDrawer.
|
||||
|
||||
> [!NOTE]
|
||||
> The class for your custom type must have the `[Serializable]` tag in its source code to create a custom PropertyDrawer.
|
||||
|
||||
To create a custom PropertyDrawer:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. [!include[create-c-script-project](./snippets/vs-create-c-script-project.md)]
|
||||
|
||||
3. Enter a name, such as `CounterDrawer`, for the new script file.
|
||||
|
||||
4. Press Enter.
|
||||
|
||||
5. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
6. Remove the `Start` and `Update` functions and their comments from the script file.
|
||||
|
||||
7. Above the line that defines your new `public class`, add a `[CustomPropertyDrawer]` attribute.
|
||||
|
||||
8. In the parameters for the `[CustomPropertyDrawer]` attribute, specify a `type of` parameter with the name of the type you want to assign to this PropertyDrawer, exactly as it appears in Unity.
|
||||
|
||||
9. Change the `MonoBehaviour` class at the end of your `public class` definition to `PropertyDrawer`.
|
||||
|
||||
> [!NOTE]
|
||||
> After you create a custom PropertyDrawer, you must generate the required property provider scripts from your Visual Scripting Project Settings. For more information, see [Configure project settings](vs-configuration.md).
|
||||
|
||||
The following is an example of a finished PropertyDrawer script:
|
||||
|
||||
```csharp
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
[CustomPropertyDrawer](type of(<Counter>))]
|
||||
public class CounterDrawer : PropertyDrawer
|
||||
{
|
||||
// Draw the property inside the given rect
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Using BeginProperty / EndProperty on the parent property means that
|
||||
// prefab override logic works on the entire property.
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
// Draw label
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
|
||||
// Don't indent child fields
|
||||
var indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
// Calculate rects
|
||||
var amountRect = new Rect(position.x, position.y, 30, position.height);
|
||||
var unitRect = new Rect(position.x + 35, position.y, 50, position.height);
|
||||
var nameRect = new Rect(position.x + 90, position.y, position.width - 90, position.height);
|
||||
|
||||
// Draw fields - passs GUIContent.none to each so they are drawn without labels
|
||||
EditorGUI.PropertyField(amountRect, property.FindPropertyRelative("amount"), GUIContent.none);
|
||||
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("unit"), GUIContent.none);
|
||||
EditorGUI.PropertyField(nameRect, property.FindPropertyRelative("name"), GUIContent.none);
|
||||
|
||||
// Set indent back to what it was
|
||||
EditorGUI.indentLevel = indent;
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To create the rest of your custom PropertyDrawer, you must decide what fields you must display, and how you want them to display in the Editor's interface. For example, you might want to use the UIElements module to create your PropertyDrawer, or decide to use Unity's IMGUI module.
|
||||
|
||||
For more information on how to create and design a custom PropertyDrawer, see the [PropertyDrawer class](https://docs.unity3d.com/ScriptReference/PropertyDrawer.html) in the main Unity Scripting API and its related methods.
|
||||
|
@ -0,0 +1,82 @@
|
||||
# Add documentation to a Custom C# node
|
||||
|
||||
You can also add [Graph Inspector](vs-interface-overview.md#the-graph-inspector) documentation to a Custom C# node. Visual Scripting displays the documentation in the Graph Inspector when you select a node in a Script Graph. The documentation isn't required to use the node, but can help your users understand the purpose and usage of a node.
|
||||
|
||||
To add documentation to a node:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
> [!NOTE]
|
||||
> If you already have an **Editor** folder in your project, you can skip Steps 2-3.
|
||||
|
||||
2. Right-click your **Assets** folder or select **Add** (+), then select **Folder**.
|
||||
|
||||
1. Name the folder **Editor**.
|
||||
|
||||
3. Do one of the following:
|
||||
|
||||
- Right-click your **Editor** folder in the Project window's folder list.
|
||||
- Right-click anywhere in the Project window's preview pane with your **Editor** folder selected.
|
||||
|
||||
4. [!include[create-c-script](./snippets/vs-create-c-script-project.md)]
|
||||
|
||||
5. Enter a name, such as `MyNodeDescriptor` for the new script file.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
6. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
7. In your external editor, copy and paste the following code into the C# script:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
[Descriptor(typeof(MyNode))]
|
||||
public class MyNodeDescriptor : UnitDescriptor<MyNode>
|
||||
{
|
||||
public MyNodeDescriptor(MyNode unit) : base(unit) {}
|
||||
|
||||
protected override void DefinedPort(IUnitPort port, UnitPortDescription description)
|
||||
{
|
||||
base.DefinedPort(port, description);
|
||||
switch (port.key)
|
||||
{
|
||||
case "inputTrigger":
|
||||
description.summary = "Trigger the concatenation of two strings, myValueA and myValueB, and return the result string on the Result port.";
|
||||
break;
|
||||
case "myValueA":
|
||||
description.summary = "First string value.";
|
||||
break;
|
||||
case "myValueB":
|
||||
description.summary = "Second string value.";
|
||||
break;
|
||||
case "outputTrigger":
|
||||
description.summary = "Execute the next action in the Script Graph after concatenating myValueA and myValueB.";
|
||||
break;
|
||||
case "result":
|
||||
description.summary = "The result string obtained from concatenating myValueA and myValueB.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
You can modify the script to suit the specifics of your own node.<br/>
|
||||
|
||||
8. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
9. Do one of the following:
|
||||
|
||||
- [!include[open-graph-w-node](./snippets/custom-c-nodes/vs-open-graph-w-node.md)].
|
||||
- [!include[ff-add-node](./snippets/custom-c-nodes/vs-ff-add-node.md)]
|
||||
|
||||
10. Select the node and open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector) to view your documentation.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you add documentation to a node, you can choose to further customize the node with [node class and port attributes](vs-create-custom-node-attributes-reference.md).
|
@ -0,0 +1,68 @@
|
||||
# Add logic to a Custom C# node
|
||||
|
||||
> [!NOTE]
|
||||
> To add logic to a node, you must create a Custom C# node and add ports. [!include[vs-tasks-note-end](./snippets/custom-c-nodes/vs-tasks-note-end.md)]
|
||||
|
||||
After you create a Custom C# node and [add ports](vs-create-custom-node-add-ports.md), you can add logic to a node. Add logic to tell Visual Scripting what the node does with any data it receives from its ports.
|
||||
|
||||
To add logic to a node:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. [!include[open-existing-external-code](./snippets/vs-open-existing-external-code.md)]
|
||||
|
||||
3. In your external editor, add any logic for the node within the lambda expression that handles the assignment of the `inputTrigger`. For example, you can take the values of the [two `string` input ports added in the previous example](vs-create-custom-node-add-ports.md#add-value-ports) and concatenate them, as shown in the following code:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyNode : Unit
|
||||
{
|
||||
[DoNotSerialize]
|
||||
public ControlInput inputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ControlOutput outputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueA;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueB;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueOutput result;
|
||||
|
||||
private string resultValue;
|
||||
protected override void Definition()
|
||||
{
|
||||
//The lambda to execute our node action when the inputTrigger port is triggered.
|
||||
inputTrigger = ControlInput("inputTrigger", (flow) =>
|
||||
{
|
||||
//Making the resultValue equal to the input value from myValueA concatenating it with myValueB.
|
||||
resultValue = flow.GetValue<string>(myValueA) + flow.GetValue<string>(myValueB) + "!!!";
|
||||
return outputTrigger;
|
||||
});
|
||||
outputTrigger = ControlOutput("outputTrigger");
|
||||
|
||||
myValueA = ValueInput<string>("myValueA", "Hello ");
|
||||
myValueB = ValueInput<string>("myValueB", String.Empty);
|
||||
result = ValueOutput<string>("result", (flow) => resultValue);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
5. Do one of the following:
|
||||
|
||||
- [!include[open-graph-w-node](./snippets/custom-c-nodes/vs-open-graph-w-node.md)].
|
||||
- [!include[ff-add-node](./snippets/custom-c-nodes/vs-ff-add-node.md)]
|
||||
|
||||
## Next steps
|
||||
|
||||
After you add logic to a node, [add relations](vs-create-custom-node-add-relations.md) to ensure that the node displays correctly in Visual Scripting.
|
@ -0,0 +1,118 @@
|
||||
# Add ports to a Custom C# node
|
||||
|
||||
> [!NOTE]
|
||||
> To add ports to your node, you must create the C# file for the node. [!include[vs-tasks-note-end](./snippets/custom-c-nodes/vs-tasks-note-end.md)]
|
||||
|
||||
After you create a Custom C# node, add ports to allow the node to send and receive data or trigger other nodes in a Script Graph.
|
||||
|
||||
To add ports to a node:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. [!include[open-existing-external-code](./snippets/vs-open-existing-external-code.md)]
|
||||
|
||||
## Add control ports
|
||||
|
||||
3. In your external editor, under the class definition for the node, add two public variables: one with a **ControlInput** type and one with a **ControlOutput** type.
|
||||
|
||||
4. In the `Definition` method for the node, use the variables to define the control ports, as shown below:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyNode : Unit
|
||||
{
|
||||
[DoNotSerialize] // No need to serialize ports.
|
||||
public ControlInput inputTrigger; //Adding the ControlInput port variable
|
||||
|
||||
[DoNotSerialize] // No need to serialize ports.
|
||||
public ControlOutput outputTrigger;//Adding the ControlOutput port variable.
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
//Making the ControlInput port visible, setting its key and running the anonymous action method to pass the flow to the outputTrigger port.
|
||||
inputTrigger = ControlInput("inputTrigger", (flow) => { return outputTrigger; });
|
||||
//Making the ControlOutput port visible and setting its key.
|
||||
outputTrigger = ControlOutput("outputTrigger");
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
5. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
6. Do one of the following:
|
||||
- [!include[open-graph-w-node](./snippets/custom-c-nodes/vs-open-graph-w-node.md)].
|
||||
- [!include[ff-add-node](./snippets/custom-c-nodes/vs-ff-add-node.md)]
|
||||
|
||||
If you used the previous code sample, Visual Scripting adds input and output control ports to the node.
|
||||
|
||||

|
||||
|
||||
## Add value ports
|
||||
|
||||
8. In your external editor, under the class definition for the node, add any number of variables with either a **Generic** or specific type value:
|
||||
|
||||
- **Generic**: The port can receive or output any data type. Corresponds to Unity's **Object** type.
|
||||
- **Specific Type Value**: The port can only receive or output a specific data type. For example, `string`, `float`, or `integer`.
|
||||
|
||||
For more information on types in Visual Scripting, see [Object types](vs-types.md).
|
||||
|
||||
9. In the `Definition` method for the node, use the variables to define the value ports. In the example below, there are two input ports with a type value of `string`, and one `string` output port:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyNode : Unit
|
||||
{
|
||||
[DoNotSerialize]
|
||||
public ControlInput inputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ControlOutput outputTrigger;
|
||||
|
||||
[DoNotSerialize] // No need to serialize ports
|
||||
public ValueInput myValueA; // Adding the ValueInput variable for myValueA
|
||||
|
||||
[DoNotSerialize] // No need to serialize ports
|
||||
public ValueInput myValueB; // Adding the ValueInput variable for myValueB
|
||||
|
||||
[DoNotSerialize] // No need to serialize ports
|
||||
public ValueOutput result; // Adding the ValueOutput variable for result
|
||||
|
||||
private string resultValue; // Adding the string variable for the processed result value
|
||||
protected override void Definition()
|
||||
{
|
||||
inputTrigger = ControlInput("inputTrigger", (flow) => { return outputTrigger; });
|
||||
outputTrigger = ControlOutput("outputTrigger");
|
||||
|
||||
//Making the myValueA input value port visible, setting the port label name to myValueA and setting its default value to Hello.
|
||||
myValueA = ValueInput<string>("myValueA", "Hello ");
|
||||
//Making the myValueB input value port visible, setting the port label name to myValueB and setting its default value to an empty string.
|
||||
myValueB = ValueInput<string>("myValueB", string.Empty);
|
||||
//Making the result output value port visible, setting the port label name to result and setting its default value to the resultValue variable.
|
||||
result = ValueOutput<string>("result", (flow) => { return resultValue; });
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
5. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
11. Do one of the following:
|
||||
- [!include[open-graph-w-node](./snippets/custom-c-nodes/vs-open-graph-w-node.md)].
|
||||
- [!include[ff-add-node](./snippets/custom-c-nodes/vs-ff-add-node.md)]
|
||||
|
||||
If you used the previous code sample, Visual Scripting adds two input ports, **My Value A** and **My Value B**, and one output port, **Result** to the node.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you add ports to a node, [add logic](vs-create-custom-node-add-logic.md) to tell the node what to do with the data it receives.
|
@ -0,0 +1,82 @@
|
||||
# Add relations to a Custom C# node
|
||||
|
||||
> [!NOTE]
|
||||
> To add logic to a node, you must create a Custom C# node and add ports. [!include[vs-tasks-note-end](./snippets/custom-c-nodes/vs-tasks-note-end.md)]
|
||||
|
||||
After you [add ports](vs-create-custom-node-add-ports.md) and [add logic](vs-create-custom-node-add-logic.md) to a node, relations help Visual Scripting correctly display a Custom C# node in a Script Graph.
|
||||
|
||||
To add relations to a node:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. [!include[open-existing-external-code](./snippets/vs-open-existing-external-code.md)]
|
||||
|
||||
3. In your external editor, add relations in the format `$RelationType$($Port1$, $Port2$)`, where `$RelationType$` is the relation type you want to assign between the ports you specify as `$Port1$` or `$Port2$`.
|
||||
|
||||
For example, to assign relations to the previous example node:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyNode : Unit
|
||||
{
|
||||
[DoNotSerialize]
|
||||
public ControlInput inputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ControlOutput outputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueA;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueB;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueOutput result;
|
||||
|
||||
private string resultValue;
|
||||
protected override void Definition()
|
||||
{
|
||||
inputTrigger = ControlInput("inputTrigger", (flow) =>
|
||||
{
|
||||
resultValue = flow.GetValue<string>(myValueA) + flow.GetValue<string>(myValueB) + "!!!";
|
||||
return outputTrigger;
|
||||
});
|
||||
outputTrigger = ControlOutput("outputTrigger");
|
||||
|
||||
myValueA = ValueInput<string>("myValueA", "Hello ");
|
||||
myValueB = ValueInput<string>("myValueB", String.Empty);
|
||||
result = ValueOutput<string>("result", (flow) => resultValue);
|
||||
|
||||
Requirement(myValueA, inputTrigger); //Specifies that we need the myValueA value to be set before the node can run.
|
||||
Requirement(myValueB, inputTrigger); //Specifies that we need the myValueB value to be set before the node can run.
|
||||
Succession(inputTrigger, outputTrigger); //Specifies that the input trigger port's input exits at the output trigger port. Not setting your succession also dims connected nodes, but the execution still completes.
|
||||
Assignment(inputTrigger,result);//Specifies that data is written to the result string output when the inputTrigger is triggered.
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
For more information on relation types, see [Custom C# nodes](vs-create-custom-node.md#relation-types).
|
||||
|
||||
4. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
5. Do one of the following:
|
||||
|
||||
- [!include[open-graph-w-node](./snippets/custom-c-nodes/vs-open-graph-w-node.md)].
|
||||
- [!include[ff-add-node](./snippets/custom-c-nodes/vs-ff-add-node.md)]
|
||||
|
||||
6. In the [Graph toolbar](vs-interface-overview.md#the-graph-toolbar), enable **Relations**.
|
||||
|
||||
Visual Scripting displays the relations you assigned to the Custom C# node. If you used the previous code sample, the node's relations might look like the following image:
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you add relations to a node, you can choose to [add documentation](vs-create-custom-node-add-docs.md) or [customize the node with attributes](vs-create-custom-node-attributes-reference.md).
|
@ -0,0 +1,267 @@
|
||||
# Custom C# node attributes reference
|
||||
|
||||
You can add attributes to a node class and port variable definitions to customize the look of a Custom C# node.
|
||||
|
||||
## Node class attributes
|
||||
|
||||
You can customize the titles that appear on a node, where it appears in the fuzzy finder, and its icon. Node class attributes must be placed above the node class definition in a node's C# script.
|
||||
|
||||
Visual Scripting has 5 node class attributes:
|
||||
|
||||
- [UnitTitle](#unittitle)
|
||||
- [UnitShortTitle](#unitshorttitle)
|
||||
- [UnitSubtitle](#unitsubtitle)
|
||||
- [UnitCategory](#unitcategory)
|
||||
- [TypeIcon](#typeicon)
|
||||
|
||||
|
||||
Usually, Visual Scripting automatically applies any changes you make to a node's class attributes after you save the C# file.
|
||||
|
||||
### UnitTitle
|
||||
|
||||

|
||||
|
||||
You can specify a `[UnitTitle]` to display a different title than the node's class name on the node when it appears in a Script Graph, and when you view details about the node in the Graph Inspector:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[UnitTitle("My New Title")]
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
...
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `[UnitTitle]` attribute overrides the node's class name.
|
||||
|
||||
### UnitShortTitle
|
||||
|
||||

|
||||
|
||||
You can specify a `[UnitShortTitle]` to display a different title on the node when it appears in a Script Graph:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[UnitShortTitle("Short Title")]
|
||||
[UnitTitle("My New Title")]
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
...
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `[UnitShortTitle]` only appears on the node in a Script Graph. The `[UnitTitle]` or node class name still displays in the Graph Inspector.
|
||||
|
||||
### UnitSubtitle
|
||||
|
||||

|
||||
|
||||
You can add a `[UnitSubtitle]` to add a line of text below the `[UnitTitle]`, `[UnitShortTitle]`, or node class name when a node appears in a Script Graph:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[UnitSubtitle("It's a subtitle!")]
|
||||
[UnitShortTitle("Short Title")]
|
||||
[UnitTitle("My New Title")]
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
...
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `[UnitSubtitle]` doesn't appear in the Graph Inspector.
|
||||
|
||||
### UnitCategory
|
||||
|
||||

|
||||
|
||||
You can specify a `[UnitCategory]` to tell Visual Scripting where to place the node in the fuzzy finder:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[UnitCategory("FirstLevel/SecondLevel")]
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
...
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Replace `FirstLevel` with the name of the top-level category in the fuzzy finder where you want Visual Scripting to place the node. Replace `SecondLevel` with the name of a subcategory. Visual Scripting creates the categories if they don't already exist in the fuzzy finder.
|
||||
|
||||
> [!NOTE]
|
||||
> You must [regenerate your Node Library](vs-configuration.md) for changes made to a node's `[UnitCategory]` to take effect.
|
||||
|
||||
### TypeIcon
|
||||
|
||||

|
||||
|
||||
You can use the `[TypeIcon]` attribute to change the icon that appears on a node when it appears in a Script Graph:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[TypeIcon(typeof(ToggleValue))]
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
...
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
The icon for the node changes in the Graph Inspector, too.
|
||||
|
||||
> [!NOTE]
|
||||
> You can't point to your own custom icons from this attribute. You must use an icon from the Visual Scripting icons library, which includes all Unity types.
|
||||
|
||||
|
||||
## Port attributes
|
||||
|
||||
Custom nodes have one mandatory port attribute and one optional port attribute: [DoNotSerialize](#donotserialize) and [PortLabelHidden](#portlabelhidden), respectively. Port attributes must be placed above your variable declarations for each port variable in the node.
|
||||
|
||||
Visual Scripting automatically applies any changes you make to a node's port attributes after you save the script file.
|
||||
|
||||
### DoNotSerialize
|
||||
|
||||
`[DoNotSerialize]` is a mandatory attribute for all ports on custom nodes. Add this attribute to avoid serialization of data that shouldn't be serialized:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[UnitShortTitle("Short Title")]
|
||||
[UnitTitle("My New Title")]
|
||||
[UnitCategory("My Nodes")]
|
||||
[UnitSubtitle("It's a subtitle!")]
|
||||
[TypeIcon(typeof(Color))]
|
||||
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
[DoNotSerialize]
|
||||
public ControlInput inputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ControlOutput outputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueA;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueB;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueOutput result;
|
||||
|
||||
private string resultValue;
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### PortLabelHidden
|
||||
|
||||

|
||||
|
||||
You can add the `[PortLabelHidden]` attribute to hide the name label for any port on a node when it appears in a Script Graph:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[UnitShortTitle("Short Title")]
|
||||
[UnitTitle("My New Title")]
|
||||
[UnitCategory("My Nodes")]
|
||||
[UnitSubtitle("It's a subtitle!")]
|
||||
[TypeIcon(typeof(Color))]
|
||||
|
||||
public class MyNodeAfter : Unit
|
||||
{
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ControlInput inputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]
|
||||
public ControlOutput outputTrigger;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueA;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValueB;
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueOutput result;
|
||||
|
||||
private string resultValue;
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The port's label is still visible in the Graph Inspector. Use the same name in a port's variable definition and the port's key in the `Definition` method for the node's class, as shown:
|
||||
|
||||
```C#
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyNode : Unit
|
||||
{
|
||||
...
|
||||
|
||||
[DoNotSerialize, PortLabelHidden]
|
||||
public ValueInput myValueA;
|
||||
|
||||
[DoNotSerialize, PortLabelHidden]
|
||||
public ValueInput myValueB;
|
||||
|
||||
...
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
...
|
||||
|
||||
myValueA = ValueInput<string>("myValueA", "Hello ");
|
||||
myValueB = ValueInput<string>("myValueB", String.Empty);
|
||||
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
@ -0,0 +1,50 @@
|
||||
# Create a new simple Custom C# node
|
||||
|
||||
You can create a Custom C# node to run your own custom logic in a Script Graph. For more information on Custom C# nodes, see [Custom C# nodes](vs-create-custom-node.md).
|
||||
|
||||
To create a new simple Custom C# node:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. Right-click a folder in the Project window's folder list, or anywhere in the Project window's preview pane, and go to **Create** > **C# Script**.
|
||||
|
||||
3. Enter a name, such as `MyNode`, for the new script file.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
4. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
5. In your external editor, copy and paste the following code into your C# script:
|
||||
|
||||
```C#
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyNode : Unit
|
||||
{
|
||||
protected override void Definition() //The method to set what our node will be doing.
|
||||
{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
6. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
7. [!include[regen-node-library](./snippets/vs-regen-node-library.md)]
|
||||
|
||||
> [!NOTE]
|
||||
> If you don't regenerate your Node Library, the node won't appear in Visual Scripting's fuzzy finder.
|
||||
|
||||
8. [Open a Script Graph](vs-open-graph-edit.md) where you want to add your new node.
|
||||
|
||||
9. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]
|
||||
|
||||
1. The node appears as `My Node` at the end of the fuzzy finder list. Select the node to add it to your graph.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you create the basic start to a node and add it to Visual Scripting's fuzzy finder, [add ports](vs-create-custom-node-add-ports.md) so your node can send and receive data.
|
@ -0,0 +1,78 @@
|
||||
# Custom C# nodes
|
||||
|
||||
You can create your own Custom C# node with a C# script. Use your node in Script Graphs to run your own custom logic, and provide the script file to other users to let them use it in their own Visual Scripting projects.
|
||||
|
||||
You can create nodes that change the flow of logic in your graph, nodes that manipulate data, or both. You can also create [nodes for custom events](vs-custom-events.md).
|
||||
|
||||
To create a Custom C# node, you must:
|
||||
|
||||
1. [Create a C# script](#create-the-initial-c-script).
|
||||
2. [Add ports](#add-ports).
|
||||
3. [Add logic](#add-logic).
|
||||
4. [Add relations](#add-relations).
|
||||
|
||||
|
||||
## Create the initial C# script
|
||||
|
||||
All custom nodes start with a C# file.
|
||||
|
||||
After you create a C# file, you must regenerate your Node Library through your [project settings](vs-configuration.md). This allows Visual Scripting to recognize your Custom C# node and add it to [the fuzzy finder](vs-interface-overview.md#the-fuzzy-finder) for use in your project's graphs.
|
||||
|
||||
After you regenerate your Node Library the first time, you only need to regenerate your Node Library again if you change the location of a node in the fuzzy finder. You can change the location through the [[UnitCategory] attribute](vs-create-custom-node-attributes-reference.md#unitcategory).
|
||||
|
||||
For more information on how to create your initial C# script, see [Create a new simple Custom C# node](vs-create-custom-node-empty.md).
|
||||
|
||||
## Add ports
|
||||
|
||||
Add ports to a node to specify what triggers Visual Scripting to run logic in a node, and decide what data it sends or receives. For more information on ports and nodes, see [Nodes](vs-nodes.md#connections-and-ports).
|
||||
|
||||
### Port types
|
||||
|
||||
Visual Scripting has four different port types that you can add to a node:
|
||||
|
||||
- `ControlInput`: Provides a connection to a previous node, which tells Visual Scripting when to start the logic in a node.
|
||||
|
||||
- `ControlOutput`: Provides a connection to another node, which tells Visual Scripting when to run the logic for the next connected node in a Script Graph.
|
||||
|
||||
- `ValueInput`: Provides a connection that allows you to pass data into a node for use in its logic.
|
||||
|
||||
- `ValueOutput`: Provides a connection that allows you to pass data out of a node for use in other nodes.
|
||||
|
||||
You can add any number of ports to a node. You can also choose what data type the `ValueInput` or `ValueOutput` ports send and receive:
|
||||
|
||||
- **Generic**: The port can receive or output any data type. Corresponds to Unity's **Object** type.
|
||||
|
||||
- **Type Value**: The port can only receive or output a specific data type. For example, `string`, `float`, or `integer`.
|
||||
|
||||
For more information on types in Visual Scripting, see [Object types](vs-types.md). For more information on how to add ports to your node, see [Add ports to your Custom C# node](vs-create-custom-node-add-ports.md).
|
||||
|
||||
## Add logic
|
||||
|
||||
Add logic to a node to specify what it does when it runs in a Script Graph. If there isn't any internal logic written for a node, the node can't trigger another node, or modify any of the data it receives from other nodes in a Script Graph.
|
||||
|
||||
For more information on how to add logic to a node, see [Add logic to a Custom C# node](vs-create-custom-node-add-logic.md).
|
||||
|
||||
## Add relations
|
||||
|
||||
Relations help define how a node and its Play mode animations appear in Visual Scripting. Without relations, Visual Scripting doesn't know how to animate or display a node in the [Graph Editor](vs-interface-overview.md#the-graph-editor).
|
||||
|
||||
### Relation types
|
||||
|
||||
You can add three types of relations to a node to help correctly display its internal flow of logic:
|
||||
|
||||
- **Assignment**: Assignment relations are usually between a control input port and a data output port. Set an Assignment relation to tell Visual Scripting that a specific port needs to run before the node sends data to a data output port.
|
||||
|
||||
- **Succession**: Succession relations are usually between a control input port and a control output port. Set a Succession relation to tell Visual Scripting that a control input port exits at a control output port.
|
||||
|
||||
- **Requirement**: Requirement relations are usually between a control input port and a data port or ports. Set a Requirement relation to let Visual Scripting know that a specific data port or ports must have a value before the node can run any logic.
|
||||
|
||||
> [!NOTE]
|
||||
> If you don't set any Succession relations in a node, and **Dim** is enabled in [the Graph toolbar](vs-interface-overview.md#the-graph-toolbar), Visual Scripting dims your Custom C# node and any of its connected nodes in the Graph Editor during Play mode.
|
||||
|
||||
For more information on how to add relations to a node, see [Add relations to a node](vs-create-custom-node-add-relations.md).
|
||||
|
||||
## Optional steps and customization
|
||||
|
||||
After you've added relations, you can choose to [add documentation for a node](vs-create-custom-node-add-docs.md). Visual Scripting displays documentation in the [Graph Inspector](vs-interface-overview.md#the-graph-inspector) when a user selects a node in a Script Graph. Add documentation to help other users understand the purpose of each part of a node.
|
||||
|
||||
You can also choose to [customize a node with node attributes](vs-create-custom-node-attributes-reference.md). You can add specific [node class attributes](vs-create-custom-node-attributes-reference.md#node-class-attributes) to customize the entire node, or add [port attributes](vs-create-custom-node-attributes-reference.md#port-attributes) to only customize specific ports. The attribute type determines the location where you must place the attribute in the node's C# file. Node class attributes must be placed above a node class definition, while port attributes must be placed above the variable definition for each port.
|
@ -0,0 +1,57 @@
|
||||
# Create and assign a graph to an existing GameObject
|
||||
|
||||
You can use the empty graph creation flow to create a new graph file and assign it to an existing GameObject in your project.
|
||||
|
||||

|
||||
|
||||
For more information on other ways to create a graph file, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
## Create a Script Graph
|
||||
|
||||
To create a new Script Graph and assign it to an existing GameObject:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select the GameObject where you want to assign the new graph.
|
||||
|
||||
2. [!include[visual-scripting-window](./snippets/vs-visual-scripting-window.md)]
|
||||
|
||||
3. Expand **Create new Script Graph**.
|
||||
|
||||
1. Select **on selected game object**.
|
||||
|
||||
4. Choose a location to save the new graph file.
|
||||
|
||||
1. Enter a name for the graph.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||
The new graph file automatically opens in a new window.
|
||||
|
||||

|
||||
|
||||
## Create a State Graph
|
||||
|
||||
To create a new State Graph and assign it to an existing GameObject:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select the GameObject where you want to assign the new graph.
|
||||
|
||||
2. [!include[visual-scripting-window](./snippets/vs-visual-scripting-window.md)]
|
||||
|
||||
3. Expand **Create new State Graph**.
|
||||
|
||||
1. Select **on selected game object**.
|
||||
|
||||
4. Choose a location to save the new graph file.
|
||||
|
||||
1. Enter a name for the graph.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||
The new graph file automatically opens in a new window.
|
||||
|
||||
## Next steps
|
||||
|
||||
After you create a new graph, attach it to a Script Machine or State Machine to use it in your application. For more information, see [Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md).
|
@ -0,0 +1,61 @@
|
||||
# Create and assign a graph to a new GameObject
|
||||
|
||||
You can use the empty graph creation flow to create a new graph file and assign it to a new GameObject. Visual Scripting automatically creates a new GameObject with the required components for the new graph file.
|
||||
|
||||

|
||||
|
||||
For more information on other ways to create a graph file, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
To create a new graph and assign it to a new GameObject:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select the GameObject where you want to assign the new graph.
|
||||
|
||||
2. [!include[visual-scripting-window](./snippets/vs-visual-scripting-window.md)]
|
||||
|
||||
3. Expand **Create new Script Graph**.
|
||||
|
||||
1. Select **on new game object**.
|
||||
|
||||
4. Choose a location to save the new graph file.
|
||||
|
||||
1. Enter a name for the graph.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||
> [!NOTE]
|
||||
> The GameObject you create with this method has the same name as the graph file. After you have named and saved the graph file, the GameObject appears in the Hierarchy.
|
||||
|
||||
The new graph file automatically opens in a new window.
|
||||
|
||||

|
||||
|
||||
## Create a State Graph
|
||||
|
||||
To create a new State Graph and assign it to a new GameObject:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select the GameObject where you want to assign the new graph.
|
||||
|
||||
2. [!include[visual-scripting-window](./snippets/vs-visual-scripting-window.md)]
|
||||
|
||||
3. Expand **Create new State Graph**.
|
||||
|
||||
1. Select **on new game object**.
|
||||
|
||||
4. Choose a location to save the new graph file.
|
||||
|
||||
1. Enter a name for the graph.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||
> [!NOTE]
|
||||
> The GameObject you create with this method has the same name as the graph file. After you have named and saved the graph file, the GameObject appears in the Hierarchy.
|
||||
|
||||
The new graph file automatically opens in a new window.
|
||||
|
||||
## Next steps
|
||||
|
||||
After you create your new graph, attach it to a Script Machine or State Machine to use it in your application. For more information, see [Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md).
|
@ -0,0 +1,50 @@
|
||||
# Create a graph on a Script Machine or State Machine
|
||||
|
||||
You can create a new graph file directly from a Script Machine or State Machine component on a GameObject. For more information on how to create a Script Machine or State Machine, see [Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md).
|
||||
|
||||
## Create a new graph file from a Script Machine or State Machine
|
||||
|
||||
To create a new graph file from an existing Script Machine or State Machine:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select a GameObject that has a Script Machine or State Machine.
|
||||
|
||||
2. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
3. In the Inspector window, on your Script Machine or State Machine component, set the **Source** set to **Graph**.
|
||||
|
||||
1. Select **New**.
|
||||
|
||||
4. Enter a name for your new graph file.
|
||||
|
||||
5. Choose a location for the file in your project.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||

|
||||
|
||||
## Create a new embedded graph on a Script Machine or State Machine
|
||||
|
||||
You can create an embedded graph on a Script Machine or State Machine component instead of an external graph file:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select a GameObject that has a Script Machine or State Machine.
|
||||
|
||||
2. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
3. In the Inspector window, on your Script Machine or State Machine component, set the **Source** to **Embed**.
|
||||
|
||||
4. (Optional) In the **(Title)** field, enter a descriptive title for the embedded graph.
|
||||
|
||||
5. (Optional) In the **(Summary)** field, enter a brief summary of what the embedded graph does.
|
||||
|
||||
6. (Optional) To open the new embedded graph and edit, select **Edit Graph**.
|
||||
|
||||
> [!NOTE]
|
||||
> Unity recommends you create a graph file rather than an embedded graph. In some situations, an embedded graph works best. For more information on how to choose the correct graph type, see [Source types for Script Machines and State Machines](vs-graph-machine-types.md#source-types).
|
||||
|
||||
## Next steps
|
||||
|
||||
After you attach a graph to a Script Machine or State Machine, you can open the graph and edit. For more information, see [Open a graph file](vs-open-graph-edit.md).
|
@ -0,0 +1,28 @@
|
||||
# Create a new blank graph with the Project window
|
||||
|
||||
You can create a new blank graph through the Project window in the Unity Editor. Your graph contains no starter nodes, and isn't connected to any existing components in your project.
|
||||
|
||||
For more information on other ways to create a new graph file, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
To create a new blank graph:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. Right-click a folder in the Project window's folder list, or anywhere in the Project window's preview pane, and go to **Create** > **Visual Scripting**.
|
||||
|
||||
1. Do one of the following:
|
||||
|
||||
* To create a new Script Graph, select **Script Graph**.
|
||||
* To create a new State Graph, select **State Graph**.
|
||||
|
||||
3. Enter a name for the new graph.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
When you open the new graph file, the graph might look similar to the following example.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you create a new graph, attach it to a Script Machine or State Machine to use it in your application. For more information, see [Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md).
|
@ -0,0 +1,35 @@
|
||||
# Create a new unassigned graph with the empty graph creation flow
|
||||
|
||||
You can use the empty graph creation flow to create a new unassigned graph for use in your project.
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> To use the graph file, you must [attach it to a Script Machine or State Machine](vs-attach-graph-machine.md).
|
||||
|
||||
For more information on other ways to create a graph file, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
To create a new unassigned graph:
|
||||
|
||||
1. [!include[visual-scripting-window](./snippets/vs-visual-scripting-window.md)]
|
||||
|
||||
2. In the new Visual Scripting window, select one of the following options:
|
||||
|
||||
* To create a new Script Graph, select **Create new Script Graph**.
|
||||
* To create a new State Graph, select **Create new State Graph**.
|
||||
|
||||
3. Choose a location to save the new graph file.
|
||||
|
||||
1. Enter a name for the graph.
|
||||
|
||||
1. Select **Save**.
|
||||
|
||||
The new graph file automatically opens in a new window.
|
||||
|
||||
The new graph file should look similar to the following image:
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you create a new graph, attach it to a Script Machine or State Machine to use it in your application. For more information, see [Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md).
|
@ -0,0 +1,30 @@
|
||||
# Create a new graph file
|
||||
|
||||
To create a new Visual Scripting graph file, you can use the Unity Editor's Project window, Visual Scripting's empty graph creation flow, or create a graph from a Script Machine or State Machine component.
|
||||
|
||||
## Use the Project window
|
||||
|
||||
If you [create a graph with the Project window](vs-create-graph-project-window.md), the graph is blank. It contains no starter nodes, and isn't attached to any existing components in your project.
|
||||
|
||||
For more information on the Unity Editor's Project window, see [The Project window](https://docs.unity3d.com/Manual/ProjectView.html) in the Unity User Manual.
|
||||
|
||||
## Use the empty graph creation flow
|
||||
|
||||
If you use the empty graph creation flow, you have a few options for how to create your graph:
|
||||
|
||||
- You can choose to [create an unassigned graph](vs-create-graph-unassigned-flow.md). The graph isn't assigned to a GameObject.
|
||||
- You can choose to [create a graph and assign it to an existing GameObject](vs-create-graph-assign-existing-gameobject.md). Visual Scripting creates the required components on the GameObject for you to use your graph in your project.
|
||||
- You can choose to [create a graph and assign it to a new GameObject](vs-create-graph-assign-new-gameobject.md). Visual Scripting creates a new GameObject with the required components for you to use your graph in your project.
|
||||
|
||||
For more information about GameObjects, see [GameObjects](https://docs.unity3d.com/Manual/GameObjects.html) in the User Manual.
|
||||
|
||||
Any graph you create with the empty graph creation flow contains one or two initial nodes to help you get started with your graph.
|
||||
|
||||
|
||||
> [!TIP]
|
||||
> To keep your project organized, place your Visual Scripting graphs in a **Graphs** folder inside your project's **Assets** folder.
|
||||
|
||||
## Use a Script Machine or State Machine
|
||||
|
||||
You can also create a blank graph file directly on the Script Machine or State Machine component where you want to use it. For more information, see [Create a graph on a Script Machine or State Machine](vs-create-graph-on-machine.md).
|
||||
|
@ -0,0 +1,65 @@
|
||||
# Listen to a Custom Scripting Event from a C# script
|
||||
|
||||
You can use a C# script to listen for or receive a Custom Scripting Event from a Script Graph. You can use an Event receiver script to execute additional logic in your application.
|
||||
|
||||
> [!NOTE]
|
||||
> Before you can create a listener for a Custom Scripting Event node, you must create a Custom Scripting Event node and its trigger. [!include[tasks-note-end](./snippets/custom-events/vs-tasks-note-end.md)] and [Create a Custom Scripting Event Sender node](vs-create-own-custom-event-send-node.md).
|
||||
|
||||
|
||||
To receive a Custom Scripting Event from a Script Graph:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
1. [!include[right-click-project](./snippets/custom-events/vs-right-click-project.md)]
|
||||
|
||||
1. [!include[create-c-script-project](./snippets/vs-create-c-script-project.md)]
|
||||
|
||||
1. Enter a name, such as `EventReceiver`, for the new script file.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
1. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
1. In your external editor, copy and paste the following code into your C# script:
|
||||
|
||||
```csharp
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
public class EventReceiver : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
EventBus.Register<int>(EventNames.MyCustomEvent, i =>
|
||||
{
|
||||
Debug.Log("RECEIVED " + i);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
1. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. Do one of the following in the Hierarchy window:
|
||||
- Select an existing GameObject where you want to attach the new script.
|
||||
- Select **Add New** (+) and in the menu, select a new GameObject to add to your scene from any of the available options. You can also right-click anywhere in the Hierarchy window and select the same options in the context menu.
|
||||
|
||||
1. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
1. Select **Add Component**.
|
||||
|
||||
1. In the Component menu, enter the name of the script file.
|
||||
|
||||
1. Select it to add it to the GameObject.
|
||||
|
||||
1. Select **Play** from [the Unity Editor's Toolbar](https://docs.unity3d.com/Manual/Toolbar.html) to enter Play mode. If you have [a Custom Scripting Event Sender node](vs-create-own-custom-event-send-node.md) or [a C# script to trigger your Event](vs-create-own-custom-event-node-trigger-code.md), you can trigger your Custom Scripting Event.
|
||||
|
||||
The `EventReceiver` script logs the following message to the console every time the Event is triggered, as shown in the following image.
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,71 @@
|
||||
# Trigger a Custom Scripting Event from a C# script
|
||||
|
||||
You can send or trigger a Custom Scripting Event node in a Script Graph with a C# script instead of a Custom Scripting Event Sender node. For more information on how to create a Custom Scripting Event Sender node, see [Create a Custom Scripting Event Sender node](vs-create-own-custom-event-send-node.md).
|
||||
|
||||
> [!NOTE]
|
||||
> Before you can trigger a Custom Scripting Event node, you must create your Custom Scripting Event node. [!include[tasks-note-end](./snippets/custom-events/vs-tasks-note-end.md)].
|
||||
|
||||
To trigger an Event from a C# script:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
1. [!include[right-click-project](./snippets/custom-events/vs-right-click-project.md)]
|
||||
|
||||
1. [!include[create-c-script-project](./snippets/vs-create-c-script-project.md)]
|
||||
|
||||
1. Enter a name, such as `CodeTriggerCustomEvent`, for the new script file.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
1. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
1. In your external editor, copy and paste the following code into your C# script:
|
||||
|
||||
```csharp
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class CodeTriggerCustomEvent : MonoBehaviour
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
if (Input.anyKeyDown)
|
||||
{
|
||||
//Trigger the previously created Custom Scripting Event MyCustomEvent with the integer value 2.
|
||||
EventBus.Trigger(EventNames.MyCustomEvent, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
1. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. Do one of the following in the Hierarchy window:
|
||||
- Select an existing GameObject where you want to attach the new script.
|
||||
- Select **Add New** (+) and in the menu, select a new GameObject to add to your scene from any of the available options. You can also right-click anywhere in the Hierarchy window and select the same options in the context menu.
|
||||
|
||||
1. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
1. Select **Add Component**.
|
||||
|
||||
1. In the Component menu, enter the name of the script file.
|
||||
|
||||
1. Select it to add it to the GameObject.
|
||||
|
||||

|
||||
|
||||
1. Select **Play** from [the Unity Editor's Toolbar](https://docs.unity3d.com/Manual/Toolbar.html) to enter Play mode.
|
||||
|
||||
1. Press any key on keyboard in the [Game view](https://docs.unity3d.com/Manual/GameView.html).
|
||||
|
||||
Visual Scripting triggers your Event in any Script Graph in the current scene that contains the Custom Scripting Event node.
|
||||
|
||||
## Next steps
|
||||
|
||||
After you create the script, you can [create a script to listen to your Event](vs-create-own-custom-event-listen-code.md).
|
||||
|
||||
You can also [create an Event Sender node](vs-create-own-custom-event-send-node.md) to trigger the Event from another Script Graph or location in the same Script Graph.
|
@ -0,0 +1,80 @@
|
||||
# Create a Custom Scripting Event node
|
||||
|
||||
You can create a Custom Scripting Event node with a C# script. With C#, you can customize all aspects of your Custom Scripting Event, unlike a Visual Scripting custom Event. For more information on the different types of custom Events, see [Custom Events](vs-custom-events.md).
|
||||
|
||||
To create a Custom Scripting Event node:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
1. [!include[right-click-project](./snippets/custom-events/vs-right-click-project.md)]
|
||||
|
||||
1. [!include[create-c-script-project](./snippets/vs-create-c-script-project.md)]
|
||||
|
||||
1. Enter a name, such as `MyEventNode`, for the new script file.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
1. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
1. In your external editor, copy and paste the following code into the C# script:
|
||||
|
||||
```csharp
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
//Register a string name for your Custom Scripting Event to hook it to an Event. You can save this class in a separate file and add multiple Events to it as public static strings.
|
||||
public static class EventNames
|
||||
{
|
||||
public static string MyCustomEvent = "MyCustomEvent";
|
||||
}
|
||||
|
||||
[UnitTitle("On my Custom Event")]//The Custom Scripting Event node to receive the Event. Add "On" to the node title as an Event naming convention.
|
||||
[UnitCategory("Events\\MyEvents")]//Set the path to find the node in the fuzzy finder as Events > My Events.
|
||||
public class MyCustomEvent : EventUnit<int>
|
||||
{
|
||||
[DoNotSerialize]// No need to serialize ports.
|
||||
public ValueOutput result { get; private set; }// The Event output data to return when the Event is triggered.
|
||||
protected override bool register => true;
|
||||
|
||||
// Add an EventHook with the name of the Event to the list of Visual Scripting Events.
|
||||
public override EventHook GetHook(GraphReference reference)
|
||||
{
|
||||
return new EventHook(EventNames.MyCustomEvent);
|
||||
}
|
||||
protected override void Definition()
|
||||
{
|
||||
base.Definition();
|
||||
// Setting the value on our port.
|
||||
result = ValueOutput<int>(nameof(result));
|
||||
}
|
||||
// Setting the value on our port.
|
||||
protected override void AssignArguments(Flow flow, int data)
|
||||
{
|
||||
flow.SetValue(result, data);
|
||||
}
|
||||
}
|
||||
```
|
||||
1. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
1. [!include[regen-node-library](./snippets/vs-regen-node-library.md)]
|
||||
|
||||
1. [Open a Script Graph](vs-open-graph-edit.md) where you want to add your new node.
|
||||
|
||||
1. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)].
|
||||
|
||||
1. Go to **Events** > **My Events**.
|
||||
|
||||
1. Select your **On My Custom Event** node to add it to the graph.
|
||||
|
||||
> [!NOTE]
|
||||
> If you change the `UnitTitle` or `UnitCategory` attributes for the node in your code, the node appears in the location in the fuzzy finder with the name that you specify.
|
||||
|
||||

|
||||
|
||||
After you regenerate your Node Library, the Custom Scripting Event node appears in the fuzzy finder. If you didn't change the `[UnitCategory]` or `[UnitTitle]` from the sample code, then the fuzzy finder displays the node under **Events** > **MyEvents**, as the **On my Custom Event** node. For more information on the fuzzy finder, see [The interface](vs-interface-overview.md#the-fuzzy-finder).
|
||||
|
||||
## Next steps
|
||||
|
||||
After you create your Custom Scripting Event node, you can [create a Custom Scripting Event Sender node](vs-create-own-custom-event-send-node.md) to trigger your Event from another Script Graph or location in the same Script Graph. You can also [create a script to trigger your Event from code](vs-create-own-custom-event-node-trigger-code.md) or [create a script to listen to your Event](vs-create-own-custom-event-listen-code.md).
|
@ -0,0 +1,102 @@
|
||||
# Create a Custom Scripting Event Sender node
|
||||
|
||||
> [!NOTE]
|
||||
> Before you create a Custom Scripting Event Sender node, you must create a Custom Scripting Event node. [!include[tasks-note-end](./snippets/custom-events/vs-tasks-note-end.md)].
|
||||
|
||||
After you create a Custom Scripting Event node, you can create a Custom Scripting Event Sender node to trigger the Event from any other Script Graph in the same scene, or the same Script Graph.
|
||||
|
||||
You can also choose to create a separate script to trigger the Event from code. For more information, see [Trigger a Custom Scripting Event from a C# script](vs-create-own-custom-event-node-trigger-code.md).
|
||||
|
||||
## Create a node and add it to the fuzzy finder
|
||||
|
||||
To create a Custom Scripting Event Sender node and add it to the fuzzy finder:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
1. [!include[right-click-project](./snippets/custom-events/vs-right-click-project.md)]
|
||||
|
||||
1. [!include[create-c-script-project](./snippets/vs-create-c-script-project.md)]
|
||||
|
||||
1. Enter a name, such as `SendMyEventNode`, for the new script file.
|
||||
|
||||
1. Press Enter.
|
||||
|
||||
1. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)]
|
||||
|
||||
1. In your external editor, copy and paste the following code into the C# script:
|
||||
|
||||
```csharp
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
//Custom node to send the Event
|
||||
[UnitTitle("Send My Custom Event")]
|
||||
[UnitCategory("Events\\MyEvents")]//Setting the path to find the node in the fuzzy finder as Events > My Events.
|
||||
public class SendMyEvent : Unit
|
||||
{
|
||||
[DoNotSerialize]// Mandatory attribute, to make sure we don’t serialize data that should never be serialized.
|
||||
[PortLabelHidden]// Hide the port label, as we normally hide the label for default Input and Output triggers.
|
||||
public ControlInput inputTrigger { get; private set; }
|
||||
[DoNotSerialize]
|
||||
public ValueInput myValue;
|
||||
[DoNotSerialize]
|
||||
[PortLabelHidden]// Hide the port label, as we normally hide the label for default Input and Output triggers.
|
||||
public ControlOutput outputTrigger { get; private set; }
|
||||
|
||||
protected override void Definition()
|
||||
{
|
||||
|
||||
inputTrigger = ControlInput(nameof(inputTrigger), Trigger);
|
||||
myValue = ValueInput<int>(nameof(myValue),1);
|
||||
outputTrigger = ControlOutput(nameof(outputTrigger));
|
||||
Succession(inputTrigger, outputTrigger);
|
||||
}
|
||||
|
||||
//Send the Event MyCustomEvent with the integer value from the ValueInput port myValueA.
|
||||
private ControlOutput Trigger(Flow flow)
|
||||
{
|
||||
EventBus.Trigger(EventNames.MyCustomEvent, flow.GetValue<int>(myValue));
|
||||
return outputTrigger;
|
||||
}
|
||||
}
|
||||
```
|
||||
1. [!include[save-script](./snippets/vs-save-script.md)]
|
||||
|
||||
1. [!include[return-unity](./snippets/vs-return-unity.md)]
|
||||
|
||||
1. [!include[regen-node-library](./snippets/vs-regen-node-library.md)]
|
||||
|
||||
After you regenerate your Node Library, the Custom Scripting Event Sender node appears in the fuzzy finder. If you didn't change the `[UnitCategory]` or `[UnitTitle]` from the sample code, then the fuzzy finder displays the node under **Events** > **MyEvents**, as the **Send My Custom Event** node. For more information on the fuzzy finder, see [The interface](vs-interface-overview.md#the-fuzzy-finder).
|
||||
|
||||
## Trigger your Custom Scripting Event node
|
||||
|
||||
You might use your **Send My Custom Event** node to trigger your Event based on keyboard input:
|
||||
|
||||
1. [Open a Script Graph](vs-open-graph-edit.md) where you want to add the new node. This can be the same or a different Script Graph from the one that contains your Custom Scripting Event node.
|
||||
|
||||
2. [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)].
|
||||
|
||||
1. Go to **Events** > **Input**.
|
||||
|
||||
1. Select the **On Keyboard Input** node to add it to the graph.
|
||||
|
||||
3. Right-click again in the Graph Editor to open the fuzzy finder.
|
||||
|
||||
1. Go to **Events** > **My Events**.
|
||||
|
||||
1. Select your **Send My Custom Event** node to add it to the graph.
|
||||
|
||||
4. Connect the **On Keyboard Input** node's Trigger output port to the **Send My Custom Event** node's Input Trigger input port, as shown in the following image.
|
||||
|
||||

|
||||
|
||||
5. Select **Play** from [the Unity Editor's Toolbar](https://docs.unity3d.com/Manual/Toolbar.html) to enter Play mode.
|
||||
|
||||
1. Press and release the Spacebar in the [Game view](https://docs.unity3d.com/Manual/GameView.html).
|
||||
|
||||
The Custom Scripting Event Sender node triggers the Custom Scripting Event in your graph and sends the Event the value from **My Value A**.
|
||||
|
||||
|
||||
## Next steps
|
||||
|
||||
After you create a Custom Scripting Event Sender node, you can [create a script to trigger your Event from code](vs-create-own-custom-event-node-trigger-code.md) or [create a script to listen to your Event](vs-create-own-custom-event-listen-code.md).
|
@ -0,0 +1,27 @@
|
||||
# Create or restore a backup
|
||||
|
||||
If you don't use a version control system, such as [Unity Collaborate](https://docs.unity3d.com/Manual/UnityCollaborate.html), [Git](https://git-scm.com/), or [Subversion](https://subversion.apache.org/), it's a good practice to create backups of your Visual Scripting assets and settings. Create a backup at any time from your [Project Settings](vs-configuration.md).
|
||||
|
||||
Back up your data before you update Visual Scripting to a new version. For more information on the update process, see [Update Visual Scripting](vs-update.md).
|
||||
|
||||
## Create a new backup
|
||||
|
||||
To create a new backup of your Visual Scripting assets and settings:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
1. Select **Create Backup**, then select **OK**.
|
||||
|
||||
Visual Scripting creates a .zip file, with a name in the format `Assets_YYYY_MM_DD_HH_MM_SS`, in a `Backups` folder inside the Unity Project.
|
||||
|
||||
## Restore an existing backup
|
||||
|
||||
To restore an existing backup of your Visual Scripting assets and settings:
|
||||
|
||||
1. [!include[open-project-settings](./snippets/vs-open-project-settings.md)]
|
||||
1. Select **Visual Scripting**.
|
||||
1. Select **Restore Backup**.
|
||||
|
||||
Visual Scripting opens your `Backups` folder in your system's file explorer. You can extract a .zip back-up file and import graphs and settings back into Unity.
|
||||
|
||||
For more information on how to import assets into Unity, see [Importing assets](https://docs.unity3d.com/Manual/ImportingAssets.html) in the Unity User Manual.
|
@ -0,0 +1,106 @@
|
||||
# Create a new state
|
||||
|
||||
You can create three types of State nodes in a State Graph: [Script States](#create-a-script-state), [Any States](#create-an-any-state), and [Super States](#create-a-super-state). For more information on the types of State nodes, see State Graphs in [Graphs](vs-graph-types.md#state-graphs).
|
||||
|
||||
You can also add a [Sticky Note](vs-sticky-notes.md) to add comments to a graph.
|
||||
|
||||
## Create a Script State
|
||||
|
||||
To create a new blank Script State:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[open-state-menu](./snippets/vs-open-state-menu.md)]</p></li>
|
||||
<li><p>Select <strong>Create Script State</strong>. <br/>Visual Scripting creates a new Script State node.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the Graph Inspector, choose a source for the Script State node:</p>
|
||||
<ul>
|
||||
<li><p><strong>Embed</strong>: The graph only exists on the Script State node. You can only modify the graph from the node in its parent State Graph.</p></li>
|
||||
<li><p><strong>Graph</strong>: The graph exists in a separate file. You can modify the graph outside of its parent State Graph and reuse the graph in other areas of your application.</p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>If you chose <strong>Graph</strong>:</p>
|
||||
<ol type="a">
|
||||
<li><p>Select <strong>New</strong>.</p></li>
|
||||
<li><p>Enter a name for the graph file.</p></li>
|
||||
<li><p>Choose where you want to save the new graph.</p></li>
|
||||
<li><p>Select <strong>Save</strong>.</p></li>
|
||||
</ol></li>
|
||||
</ol>
|
||||
|
||||

|
||||
|
||||
|
||||
To create a Script State from an existing Script Graph:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[open-state-menu](./snippets/vs-open-state-menu.md)]</p></li>
|
||||
<li><p>Select <strong>Create Script State</strong>. <br/>Visual Scripting creates a new Script State node.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the Graph Inspector, set the source for the Script State node to <strong>Graph</strong>.</p></li>
|
||||
<li><p>Do one of the following:</p>
|
||||
<ul>
|
||||
<li><p>Select the object picker (circle icon) and choose a compatible Script Graph from your project.</p></li>
|
||||
<li><p>Click and drag a Script Graph file from your Project window and release on the <strong>Graph</strong> field.</p></li>
|
||||
</ul></li>
|
||||
</ol>
|
||||
|
||||

|
||||
|
||||
> [!TIP]
|
||||
> Click and drag the Script Graph from your Project window into the Graph Editor to automatically create a Script State node.
|
||||
|
||||
|
||||
## Create an Any State
|
||||
|
||||
To create a new Any State node:
|
||||
|
||||
1. [!include[open-state-menu](./snippets/vs-open-state-menu.md)]
|
||||
|
||||
2. Select **Create Any State**.
|
||||
|
||||

|
||||
|
||||
|
||||
## Create a Super State
|
||||
|
||||
To create a new blank Super State:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[open-state-menu](./snippets/vs-open-state-menu.md)]</p></li>
|
||||
<li><p>Select <strong>Create Super State</strong>. <br/>Visual Scripting creates a new Super State node.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the Graph Inspector, choose a source for the Super State node:</p>
|
||||
<ul>
|
||||
<li><p><strong>Embed</strong>: The graph only exists on the Super State node. You can only modify the graph from the node in its parent State Graph.</p></li>
|
||||
<li><p><strong>Graph</strong>: The graph exists in a separate file. You can modify the graph outside of its parent State Graph and reuse the graph in other areas of your application.</p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>If you chose <strong>Graph</strong>:</p>
|
||||
<ol type="a">
|
||||
<li><p>Select <strong>New</strong>.</p></li>
|
||||
<li><p>Enter a name for the graph file.</p></li>
|
||||
<li><p>Choose where you want to save the new graph.</p></li>
|
||||
<li><p>Select <strong>Save</strong>.</p></li>
|
||||
</ol></li>
|
||||
</ol>
|
||||
|
||||

|
||||
|
||||
To create a Super State from an existing State Graph:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[open-state-menu](./snippets/vs-open-state-menu.md)]</p></li>
|
||||
<li><p>Select <strong>Create Super State</strong>. <br/>Visual Scripting creates a new Super State node.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the Graph Inspector, set the source for the Super State node to <strong>Graph</strong>.</p></li>
|
||||
<li><p>Do one of the following:</p>
|
||||
<ul>
|
||||
<li><p>Select the object picker (circle icon) and choose a compatible State Graph from your project.</p></li>
|
||||
<li><p>Click and drag a State Graph file from your Project window and release on the <strong>Graph</strong> field.</p></li>
|
||||
</ul></li>
|
||||
</ol>
|
||||
|
||||

|
||||
|
||||
> [!TIP]
|
||||
> Click and drag the State Graph from your Project window into the Graph Editor to automatically create a Super State node.
|
@ -0,0 +1,41 @@
|
||||
# Connect nodes in a Script Graph
|
||||
|
||||
Connections control the flow of logic and data in a Script Graph's nodes.
|
||||
|
||||
To connect nodes in a Script Graph:
|
||||
|
||||
1. With a Script Graph [open in the Graph window](vs-open-graph-edit.md), either find an existing node where you want to make a connection, or [add a new node to your Script Graph](vs-add-node-to-graph.md).
|
||||
|
||||
1. Do one of the following:
|
||||
- [Connect to a new node](#connect-to-a-new-node).
|
||||
- [Connect to an existing node](#connect-to-an-existing-node).
|
||||
|
||||
### Connect to a new node
|
||||
|
||||
1. Select a port and point to a blank area in your graph to start the connection.
|
||||
|
||||
1. Select again to open the fuzzy finder.
|
||||
|
||||
1. Select an entry to automatically add that node at the end of your connection.
|
||||
|
||||
### Connect to an existing node
|
||||
|
||||
1. Select a port and point to an existing port on another node.
|
||||
|
||||
1. Select the port to make the connection.
|
||||
|
||||

|
||||
|
||||
## Delete a connection
|
||||
|
||||
To delete a connection between two nodes:
|
||||
|
||||
1. With a Script Graph open in the Graph window, right-click the port at either end of a connection.
|
||||
|
||||
Visual Scripting deletes the connection.
|
||||
|
||||
## Next steps
|
||||
|
||||
After you've connected nodes together, you can continue to [add nodes to your Script Graph](vs-add-node-to-graph.md). You can also [create and add variables](vs-add-variable-graph.md), [create node groups](vs-groups.md), or [add a Subgraph](vs-nesting-add-subgraph.md).
|
||||
|
||||
You can also add a [Sticky Note](vs-sticky-notes.md) to add comments to a graph.
|
@ -0,0 +1,118 @@
|
||||
# Create a transition between states
|
||||
|
||||
To switch between states in a State Graph, you must use a Script Graph called a transition.
|
||||
|
||||
For more information on State Graphs, see [State Graphs](vs-graph-types.md#state-graphs).
|
||||
|
||||
## Create a transition with an embedded Script Graph
|
||||
|
||||
To create a new transition to another state with an embedded graph in a State Graph:
|
||||
|
||||
1. With a State Graph [open in the Graph window](vs-open-graph-edit.md), do one of the following:
|
||||
|
||||
- Right-click on the state where you want to make a transition, then in the context menu, select **Make Transition**.
|
||||
|
||||
- Select the state where you want to make a transition, then press Ctrl+click and drag away from your selected state.
|
||||
|
||||
2. Do one of the following:
|
||||
|
||||
- Select or release while on an existing state in your State Graph to connect the states with a transition.
|
||||
|
||||
- Select or release while on an empty space in the Graph Editor to automatically create a new blank Script State at the end of your transition.
|
||||
|
||||
3. Select your transition node.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, set the **Source** to **Embed**.
|
||||
|
||||
1. In the **(Title)** field, enter a title for your transition's Script Graph.
|
||||
|
||||
1. In the **(Summary)** field, enter a brief descriptive summary of your transition's Script Graph.
|
||||
|
||||
> [!NOTE]
|
||||
> If you choose to use an embedded transition Script Graph, Visual Scripting automatically provides the Trigger Transition node you need for the graph.
|
||||
|
||||
## Create a transition with an external Script Graph file
|
||||
|
||||
To create a new transition with a graph asset file in a State Graph:
|
||||
|
||||
1. With a State Graph [open in the Graph window](vs-open-graph-edit.md), do one of the following:
|
||||
|
||||
- Right-click on the state where you want to make a transition, then in the context menu, select **Make Transition**.
|
||||
|
||||
- Select the state where you want to make a transition, then press Ctrl+click and drag away from your selected state.
|
||||
|
||||
2. Do one of the following:
|
||||
|
||||
- Select or release while on an existing state in your State Graph to connect the states with a transition.
|
||||
|
||||
- Select or release while on an empty space in the Graph Editor to automatically create a new blank Script State at the end of your transition.
|
||||
|
||||
3. Select your transition node.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, set the **Source** to **Graph**.
|
||||
|
||||
1. Do one of the following:
|
||||
|
||||
- Select the object picker (circle icon). Select a Script Graph from your project.
|
||||
|
||||
- Click and drag a Script Graph file from your Project window and release on the **Graph** field.
|
||||
|
||||
- Select **New** and [create a new Script Graph](vs-create-graph.md).
|
||||
|
||||
4. Double-click the new transition node to open the transition Script Graph.
|
||||
|
||||

|
||||
|
||||
## Create a self transition with an embedded Script Graph
|
||||
|
||||
To create a new self transition for a state in a State Graph:
|
||||
|
||||
1. With a State Graph [open in the Graph window](vs-open-graph-edit.md), right-click on the state where you want to make the transition.
|
||||
|
||||
2. In the context menu, select **Make Self Transition**.
|
||||
Visual Scripting attaches a new Self Transition node to the state in the State Graph automatically.
|
||||
|
||||
3. Select your transition node.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, set the **Source** to **Embed**.
|
||||
|
||||
1. In the **(Title)** field, enter a title for your transition's Script Graph.
|
||||
|
||||
1. In the **(Summary)** field, enter a brief descriptive summary of your transition's Script Graph.
|
||||
|
||||
4. Double-click the new self transition to open the transition Script Graph.
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> If you choose to use an embedded transition Script Graph, Visual Scripting automatically provides the Trigger Transition node you need for your graph.
|
||||
|
||||
|
||||
## Create a transition with an external Script Graph file
|
||||
|
||||
To create a new transition with a graph asset file in a State Graph:
|
||||
|
||||
1. With a State Graph [open in the Graph window](vs-open-graph-edit.md), right-click on the state where you want to make the transition.
|
||||
|
||||
2. In the context menu, select **Make Self Transition**.
|
||||
Visual Scripting attaches a new Self Transition node to the state in the State Graph automatically.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, set the **Source** to **Graph**.
|
||||
|
||||
1. Do one of the following:
|
||||
|
||||
- Select the object picker (circle icon). Select a Script Graph from your project.
|
||||
|
||||
- Click and drag a Script Graph file from your Project window and release on the **Graph** field.
|
||||
|
||||
- Select **New** and [create a new Script Graph](vs-create-graph.md).
|
||||
|
||||
4. Double-click the new transition node to open the transition Script Graph.
|
@ -0,0 +1,57 @@
|
||||
# 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](vs-add-custom-event-node.md).
|
||||
|
||||
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](vs-add-custom-event-node-trigger.md).
|
||||
|
||||
Visual Scripting displays errors in the [Graph Inspector](vs-interface-overview.md#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.
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
|
||||
## 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](vs-create-own-custom-event-node.md).
|
||||
|
||||

|
||||
|
||||
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](vs-create-own-custom-event-send-node.md).
|
||||
|
||||
- For more information on how to send or trigger an Event with code, see [Trigger a Custom Scripting Event from a C# script](vs-create-own-custom-event-node-trigger-code.md).
|
||||
|
||||
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](vs-create-own-custom-Event-listen-code.md).
|
@ -0,0 +1,40 @@
|
||||
# Custom types
|
||||
|
||||
Use a C# script file to create your own object types in Unity. These types are called classes.
|
||||
|
||||
Classes are a blueprint for objects in your code. They decide what kind of data an object holds and what your code can do with that object. A class can hold multiple variables with different data types in a single object.
|
||||
|
||||
Create a custom class to use it as a type for variables and other objects in a Visual Scripting Script graph. For more information on how to add and use your own custom types in Visual Scripting, see [Use a custom type](vs-using-custom-types.md). The code you include in a C# script can also create new nodes to manipulate the data in your class.
|
||||
|
||||
For example, you might write code to keep track of the characteristics of different player characters in your application. You can create a class, `Player`, and have different variables in that class for name, character type, favorite color, or player level:
|
||||
|
||||
```csharp
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
[Serializable, Inspectable]
|
||||
public class PlayerCharacter
|
||||
{
|
||||
[Inspectable]
|
||||
public string name;
|
||||
[Inspectable]
|
||||
public string type;
|
||||
[Inspectable]
|
||||
public string color;
|
||||
[Inspectable]
|
||||
public int level;
|
||||
}
|
||||
|
||||
```
|
||||
> [!TIP]
|
||||
> The variables in the example script above use the `[Inspectable]` attribute so they can display in Unity's [Inspector window](https://docs.unity3d.com/Manual/UsingTheInspector.html) and the Visual Scripting [Graph Inspector](vs-interface-overview.md#the-graph-inspector). Without the attribute, you can't assign a value to any variables that use the `PlayerCharacter` class in a Script Graph. For more information about the `[Inspectable]` attribute, see [Use a custom type](vs-using-custom-types.md).
|
||||
|
||||
These values can be different across different instances of `Player` objects in your code. `Player1` can be Erin, a bard, who loves green and is level 5, and `Player2` can be Sam, a mage, who loves black and is level 15.
|
||||
|
||||

|
||||
|
||||
If you tried to represent the same data with basic variables, you must create a lot of nodes, as in the following example. With a custom class, you can create a single node to represent a player character's information, instead of four separate nodes.
|
||||
|
||||

|
||||
|
@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
# Working with debug messages
|
||||
|
||||
You can use debug nodes to see the result of a code segment inside the Unity console. For example, attaching a Debug node to a Variable node outputs the value of the variable.
|
||||
|
||||
> [!TIP]
|
||||
> Debugs are a useful tool when prototyping.
|
||||
|
||||
## To create a debug message
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Remove or disconnect the debugs from the graphs before producing the final executable.
|
||||
|
||||
1. Add a Script Machine component to the GameObject.
|
||||
2. Select **Edit Graph**.
|
||||
3. Do one of the following:
|
||||
- Use the starting events that are created with the script machine.
|
||||
- Add an event node to the graph.
|
||||
4. Drag and release from the node port.</br>
|
||||
The fuzzy finder appears.
|
||||
5. In the finder field, enter “Log”.</br>
|
||||
A list of Debug nodes appears.
|
||||
6. Select the relevant debug message type you want to use (for example **Log(Message)**, **Log Error(Message)** or **Log Warning(Message)**).</br>
|
||||
The select Debug node is placed in the graph and linked to the event.
|
||||
7. Drag and release from the Debug green (output) port.</br>
|
||||
The fuzzy finder appears.
|
||||
8. In the list, select the String node.</br>
|
||||
A String node appears on the graph, connected to the Debug node.v
|
||||
Enter the debug message in the string node**.**
|
||||
|
||||
> [!TIP]
|
||||
> You can link variables or GameObjects other than a string to the port to see the value in the console.
|
||||
|
||||
Whenever the graph is run and the Event is fired, the debug node executes and the text in the String appears in the console.
|
||||
|
||||
> [!NOTE]
|
||||
> The debug bar indicates the number of messages of each debug type (in the following order Message, Error, Warning).
|
||||
|
||||

|
||||
|
||||
|
@ -0,0 +1,74 @@
|
||||
# Predictive and Live Debugging
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
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 euro 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.
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||

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

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
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 game object does not have a rigidbody and provides a warning.
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

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

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

|
||||
|
||||
|
||||
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.
|
@ -0,0 +1,456 @@
|
||||
# Developer's guide
|
||||
|
||||
|
||||
|
||||
## _Misc
|
||||
|
||||
| Node | Description |
|
||||
| ---------------------------- | ------------------------------------------------------------ |
|
||||
| Formula | Outputs the result of the formula entered, which has a user specified number of input ports. Can create vector 2,3,4 and access all variables by name (object, graph, scene, application, saved). |
|
||||
| GetApplicationVariable | Gets an application variable by name. |
|
||||
| GetGraphVariable | Gets a graph variable by name. |
|
||||
| GetMember | Invokes a getter via reflection (field or property, static or instance). |
|
||||
| GetObjectVariable | Gets an object variable by name. |
|
||||
| GetSavedVariable | Gets a saved variable by name. |
|
||||
| GetSceneVariable | Gets a scene variable by name. |
|
||||
| GetVariable | Gets a graph variable by name. |
|
||||
| InvokeMember | Invokes a method via reflection (static or instance). |
|
||||
| IsApplicationVariableDefined | Returns true if the variable is defined. |
|
||||
| IsGraphVariableDefined | Returns true if the variable is defined. |
|
||||
| IsObjectVariableDefined | Returns true if the variable is defined. |
|
||||
| IsSavedVariableDefined | Returns true if the variable is defined. |
|
||||
| IsSceneVariableDefined | Returns true if the variable is defined. |
|
||||
| IsVariableDefined | Returns true if the variable is defined. |
|
||||
| This (formerly Self) | Provides a reference to the GameObject that has the Machine Component running the graph. |
|
||||
| SetApplicationVariable | Sets an application variable by name. |
|
||||
| SetGraphVariable | Sets a graph variable by name. |
|
||||
| SetMember | Invokes a setter via reflection (field or property, static or instance). |
|
||||
| SetObjectVariable | Sets an object variable by name. |
|
||||
| SetSavedVariable | Sets a saved variable by name. |
|
||||
| SetSceneVariable | Sets a scene variable by name. |
|
||||
| SetVariable | Sets a variable by name. |
|
||||
|
||||
|
||||
|
||||
## Collections
|
||||
|
||||
| Node | Description |
|
||||
| ---------- | ---------------------------------------------------------- |
|
||||
| CountItems | Provides a count of the number of items in the collection. |
|
||||
| FirstItem | Gets a reference to the first item in the collections. |
|
||||
| LastItem | Gets a reference to the last item in the collection. |
|
||||
|
||||
|
||||
|
||||
### Collections, Dictionaries
|
||||
|
||||
| Node | Description |
|
||||
| --------------------- | ------------------------------------------------------------ |
|
||||
| AddDictionaryItem | Adds Key/Value pair into dictionary. |
|
||||
| ClearDictionary | Removes all elements from the dictionary. |
|
||||
| CreateDictionary | Creates a local dictionary. |
|
||||
| DictionaryContainsKey | Returns true if the dictionary contains an entry with a matching key. |
|
||||
| GetDictionaryItem | Return value for a dictionary entry with the provided keys. |
|
||||
| MergeDictionaries | Combines the contents of two dictionaries into a single dictionary. |
|
||||
| RemoveDictionaryItem | Removes an entry from the dictionary with the provided key. |
|
||||
| SetDictionaryItem | Replaces the value of an existing entry with the provided key. |
|
||||
|
||||
|
||||
|
||||
### Collections, Lists
|
||||
|
||||
| Node | Description |
|
||||
| ---------------- | ------------------------------------------------------------ |
|
||||
| AddListItem | Adds an item to the list. |
|
||||
| ClearList | Removes all elements from the list. |
|
||||
| CreateList | Creates a local list. |
|
||||
| GetListItem | Gets the item in a list at the specified position provided by the index. |
|
||||
| InsertListItem | Inserts an item into a list at the specified position provided by the index. |
|
||||
| ListContainsItem | Returns true if the item is contained in the list. |
|
||||
| MergeLists | Combines the contents of two lists into a single list. |
|
||||
| RemoveListItem | Removes the item from the list (if it is present). |
|
||||
| RemoveListItemAt | Removes the item from the list that is at the specified position provided by the index. |
|
||||
| SetListItem | Replaces the item in the list with a new item at the specified position provided by the index. |
|
||||
|
||||
|
||||
|
||||
## Control
|
||||
|
||||
| Node | Description |
|
||||
| -------------------- | ------------------------------------------------------------ |
|
||||
| If (Formerly Branch) | Executes the True branch if the provided input is true, otherwise executes the False branch. |
|
||||
| Break | Immediately exits the current loop. |
|
||||
| Cache | Flow node reads its input value whenever a value from any source is entered and outputs it when its output port is pulled. |
|
||||
| For | A loop control. The Body branch is executed, providing an Index equal to First. If execution isn't interrupted (for example, by Break), the Index is incremented by Step. If the Index is less than Last, the Body branch is executed again. This process repeats until the Index is greater than Last, at which point the Exit branch is executed and the loop terminates. |
|
||||
| ForEach | A loop control that executes Body once for every item (provided as Item) contained in the provided collection. Once completed, the Exit branch is executed. |
|
||||
| Once | Flow node with an internal state that triggers its output only the first time it is entered. Entering a second time does not trigger the output flow. After a reset, the next time you enter, will trigger the output flow. |
|
||||
| SelectOnEnum | Provides the object associated to the enum value provided as an input. |
|
||||
| SelectOnFlow | Provides the object associated to the incoming flow branch that triggered the node. |
|
||||
| SelectOnInteger | Data branching based on an input integer. |
|
||||
| SelectOnString | Data branching based on an input string. |
|
||||
| SelectUnit | Data branching based on an input enum. |
|
||||
| Sequence | Executes a series of branches in order. To determine the order, specify the number of steps in the sequence, labelled with their order (e.g. 0, 1, 2, 3). |
|
||||
| SwitchOnEnum | Executes the branch associated to the provided enum value. |
|
||||
| SwitchOnInteger | Flow branching based on an input integer. |
|
||||
| SwitchOnString | Flow branching based on an input string. |
|
||||
| Throw | Causes an exception with the provided message. |
|
||||
| ToggleFlow | Flow branching based on whether the node is On or Off, with inputs to set or toggle its On/Off state. |
|
||||
| ToggleValue | Flow branching based on whether a value got set to its associated On/Off value. |
|
||||
| TryCatch | Executes the Try branch. If an exception occurs in that branch, execute the Catch branch. Once the Try branch completes without exceptions or the Catch branch completes, the Finally branch is executed. |
|
||||
| While | Executes the Body branch. Repeat this step as long as the provide condition is true. When that condition is no longer true, execute the Exit branch. |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
| Node | Description |
|
||||
| ------------------ | -------------------------------- |
|
||||
| TriggerCustomEvent | Triggers a custom event by name. |
|
||||
|
||||
|
||||
|
||||
## Logic
|
||||
|
||||
| Node | Description |
|
||||
| -------------- | ------------------------------------------------------------ |
|
||||
| And | Logical AND (equivalent to &&) returns true if both operands are true and returns false otherwise. |
|
||||
| Comparison | All comparisons in one node: inputs A/B, outputs < <= > >= == !=, and so on. |
|
||||
| Equal | Logical AND (equivalent to &&) returns true if both operands are true and returns false otherwise. |
|
||||
| ExclusiveOr | Exclusive OR (equivalent to ^) compares the first operand to the second operand and returns true only when inputs differ (one is true, the other is false). |
|
||||
| Greater | Greater than (equivalent to >) returns false if the relationship in the expression is false; otherwise, returns true. |
|
||||
| GreaterOrEqual | Greater than or equal to (equivalent to >=) returns false if the relationship in the expression is false; otherwise, returns true. |
|
||||
| Less | Less than (equivalent to <) returns false if the relationship in the expression is false; otherwise, returns true. |
|
||||
| LessOrEqual | Less than or equal to (equivalent to <=) returns false if the relationship in the expression is false; otherwise, returns true. |
|
||||
| Negate | Negation (equivalent to !) reverses the meaning of its operand. |
|
||||
| NotEqual | The not equal to operator (equivalent to. !=) returns true if the operands don't have the same value; otherwise, it returns false. |
|
||||
| Or | Logical OR (equivalent to \|\|) returns true if either or both operands is true and returns false otherwise. |
|
||||
|
||||
|
||||
|
||||
## Math, Generic
|
||||
|
||||
| Node | Description |
|
||||
| -------- | ------------------------------- |
|
||||
| Add | Calls the + operator on inputs. |
|
||||
| Divide | Calls the / operator on inputs. |
|
||||
| Modulo | Calls the % operator on inputs. |
|
||||
| Multiply | Call the * operator on inputs. |
|
||||
| Subtract | Calls the - operator on inputs. |
|
||||
|
||||
|
||||
|
||||
## Math, Scalar
|
||||
|
||||
| Node | Description |
|
||||
| ------------ | ------------------------------------------------------------ |
|
||||
| Absolute | Absolute returns the absolute value of an integer. |
|
||||
| Add | Sum of two floats. |
|
||||
| Average | Average of all float inputs. |
|
||||
| Divide | Divides the first float by the second float and returns the result. |
|
||||
| Exponentiate | Raises the base to an exponent. |
|
||||
| Lerp | Interpolates within a range based on a parameter. |
|
||||
| Maximum | Computes the maximum values passed in its argument. |
|
||||
| Minimum | Computes the minimum values passed in its argument. |
|
||||
| Modulo | Returns the remainder of a float divided by another float. |
|
||||
| MoveTowards | Returns the result of moving Current towards Target by up to Max Delta. |
|
||||
| Multiply | Multiplies two floats. |
|
||||
| Normalize | Equivalent to MathF.Sign. |
|
||||
| PerSecond | Multiplies the value by the duration of the frame (for example, to move smoothly from frame to frame with a fixed speed). |
|
||||
| Root | Calculates x to the root of n. |
|
||||
| Round | Rounds a float - ceil, floor or closest integer. |
|
||||
| Subtract | Subtracts the first float from the second float and returns the result. |
|
||||
| Sum | Sum of multiple floats. |
|
||||
|
||||
|
||||
|
||||
## Math, Vector2
|
||||
|
||||
| Node | Description |
|
||||
| ----------- | ------------------------------------------------------------ |
|
||||
| Absolute | Gives both the x and y values of a Vector2 a positive sign. |
|
||||
| Add | Sum of two vectors. |
|
||||
| Angle | Angle between two directional vectors. |
|
||||
| Average | Average of a series of Vector2 value. |
|
||||
| Distance | Distance between two Vector2 points. |
|
||||
| Divide | Divide the components of one Vector2 by the corresponding components of a second Vector2. |
|
||||
| DotProduct | Dot Product between two Vector2 values. |
|
||||
| Lerp | Interpolates within a range based on a parameter. |
|
||||
| Maximum | Computes the maximum values passed in its argument. |
|
||||
| Minimum | Computes the minimum values passed in its argument. |
|
||||
| Modulo | Returns a Vector2 where the components of the first vector are moduled by the corresponding components of the second vector. |
|
||||
| MoveTowards | Returns the result of moving Current towards Target by up to Max Delta. |
|
||||
| Multiply | Multiplies the corresponding components of two Vector2 values. |
|
||||
| Normalize | Returns a Vector2 with a magnitude of 1 that retains the same direction. |
|
||||
| PerSecond | Multiplies the value by the duration of the frame (for example, to move smoothly from frame to frame with a fixed speed). |
|
||||
| Project | Projects one vector onto another vector. |
|
||||
| Round | Rounds the components of a Vector2 to closest integer value. |
|
||||
| Subtract | Subtracts one Vector2 value from another Vector2 value. |
|
||||
| Sum | Adds two Vector2 values. |
|
||||
|
||||
|
||||
|
||||
## Math, Vector3
|
||||
|
||||
| Node | Description |
|
||||
| ----------- | ------------------------------------------------------------ |
|
||||
| Absolute | Gives both the x and y values of a Vector3 a positive sign. |
|
||||
| Add | Sum of two vectors. |
|
||||
| Angle | Angle between two directional vectors. |
|
||||
| Average | Average of a series of Vector3 value. |
|
||||
| Distance | Distance between two Vector3 points. |
|
||||
| Divide | Divide the components of one Vector3 by the corresponding components of a second Vector3. |
|
||||
| DotProduct | Dot Product between two Vector3 values. |
|
||||
| Lerp | Interpolates within a range based on a parameter. |
|
||||
| Maximum | Computes the maximum values passed in its argument. |
|
||||
| Minimum | Computes the minimum values passed in its argument. |
|
||||
| Modulo | Returns a Vector3 where the components of the first vector are moduled by the corresponding components of the second vector. |
|
||||
| MoveTowards | Returns the result of moving Current towards Target by up to Max Delta. |
|
||||
| Multiply | Multiplies the corresponding components of two Vector3 values. |
|
||||
| Normalize | Returns a Vector3 with a magnitude of 1 that retains the same direction. |
|
||||
| PerSecond | Multiplies the value by the duration of the frame (for example, to move smoothly from frame to frame with a fixed speed). |
|
||||
| Project | Projects one vector onto another vector. |
|
||||
| Round | Rounds the components of a Vector3 to closest integer value. |
|
||||
| Subtract | Subtracts one Vector3 value from another Vector3 value. |
|
||||
| Sum | Adds two Vector3 values. |
|
||||
|
||||
|
||||
|
||||
## Math, Vector4
|
||||
|
||||
| Node | Description |
|
||||
| ----------- | ------------------------------------------------------------ |
|
||||
| Absolute | Gives both the x and y values of a Vector4 a positive sign. |
|
||||
| Add | Sum of two vectors. |
|
||||
| Angle | Angle between two directional vectors. |
|
||||
| Average | Average of a series of Vector4 value. |
|
||||
| Distance | Distance between two Vector4 points. |
|
||||
| Divide | Divide the components of one Vector4 by the corresponding components of a second Vector4. |
|
||||
| DotProduct | Dot Product between two Vector4 values. |
|
||||
| Lerp | Interpolates within a range based on a parameter. |
|
||||
| Maximum | Computes the maximum values passed in its argument. |
|
||||
| Minimum | Computes the minimum values passed in its argument. |
|
||||
| Modulo | Returns a Vector4 where the components of the first vector are moduled by the corresponding components of the second vector. |
|
||||
| MoveTowards | Returns the result of moving Current towards Target by up to Max Delta. |
|
||||
| Multiply | Multiplies the corresponding components of two Vector4 values. |
|
||||
| Normalize | Returns a Vector4 with a magnitude of 1 that retains the same direction. |
|
||||
| PerSecond | Multiplies the value by the duration of the frame (for example, to move smoothly from frame to frame with a fixed speed). |
|
||||
| Project | Projects one vector onto another vector. |
|
||||
| Round | Rounds the components of a Vector4 to closest integer value. |
|
||||
| Subtract | Subtracts one Vector4 value from another Vector4 value. |
|
||||
| Sum | Adds two Vector4 values. |
|
||||
|
||||
|
||||
|
||||
## Nesting
|
||||
|
||||
| Node | Description |
|
||||
| ---------------------- | ------------------------------------------------------------ |
|
||||
| GraphInput | Gets the value of a graph input when the graph is used as a Subgraph. |
|
||||
| GraphOutput | Gets the value of a graph output when the graph is used as a Subgraph. |
|
||||
| StateUnit | References another state machine graph as a state in the current graph. |
|
||||
| Subgraph | References another flow graph as a Subgraph in the current graph. |
|
||||
| TriggerStateTransition | In a transition graph, triggers the transition to the target graph in the parent state machine graph. |
|
||||
|
||||
|
||||
|
||||
## Nulls
|
||||
|
||||
| Node | Description |
|
||||
| ------------ | ------------------------------------------------------------ |
|
||||
| Null | Null literal. |
|
||||
| NullCheck | Branching based on the input value being null. |
|
||||
| NullCoalesce | Returns the input value or a default value if the input value is null. |
|
||||
|
||||
|
||||
|
||||
## Time
|
||||
|
||||
| Node | Description |
|
||||
| --------------------- | ------------------------------------------------------------ |
|
||||
| Cooldown | Coroutine node that can re-trigger its output only after a certain cooldown time interval. |
|
||||
| Timer | Coroutine node that triggers its output after a time interval. |
|
||||
| WaitForEndOfFrameUnit | Coroutine node that yields return new WaitForEndOfFrame(). |
|
||||
| WaitForFlow | Coroutine node that waits until the input flow port is triggered. |
|
||||
| WaitForNextFrameUnit | Coroutine node that returns null. |
|
||||
| WaitForSecondsUnit | Coroutine node that returns new WaitForSeconds(). |
|
||||
| WaitUntilUnit | Coroutine node that returns new WaitUntill(() => value). |
|
||||
| WaitWhileUnit | Coroutine node that returns new WaitUntill(() => !value). |
|
||||
|
||||
|
||||
|
||||
## Variables
|
||||
|
||||
| Node | Description |
|
||||
| ------------- | ------------------------------------------------------------ |
|
||||
| SaveVariables | Forces saved variables to be saved to the PlayerPrefs (this is useful on platforms that do not support automatic save on quit). |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
| Node | Description |
|
||||
| ----------- | --------------------------------------------------------- |
|
||||
| UnityEvent | Called when a UnityEvent is pointed to TriggerUnityEvent. |
|
||||
| CustomEvent | Bolt's custom events, defined by name. |
|
||||
|
||||
|
||||
|
||||
### Events, Animation
|
||||
|
||||
| Node | Description |
|
||||
| --------------------- | ------------------------------------------------------------ |
|
||||
| Animation Event | Called when an animation event points to TriggerAnimationEvent. This version allows you to use the string parameter as the event name |
|
||||
| Named Animation Event | Called when an animation event points to TriggerAnimationEvent. This version allows you to use the string parameter as the event name. |
|
||||
| OnAnimatorIK | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnAnimatorIK.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnAnimatorIK.html) |
|
||||
| OnAnimatorMove | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnAnimatorMove.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnAnimatorMove.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Application
|
||||
|
||||
| Node | Description |
|
||||
| ---------------------- | ------------------------------------------------------------ |
|
||||
| OnApplicationFocus | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnApplicationFocus.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnApplicationFocus.html) |
|
||||
| OnApplicationLostFocus | Implements <br />[https://docs.unity3d.com/ScriptReference/<br />MonoBehaviour.OnApplicationFocus.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html) |
|
||||
| OnApplicationPause | [https://docs.unity3d.com/ScriptReference/<br />MonoBehaviour.OnApplicationPause.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html) |
|
||||
| OnpplicationQuit | [https://docs.unity3d.com/ScriptReference/<br />MonoBehaviour.OnApplicationQuit.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html) |
|
||||
| OnApplicationResume | Implements <br />[https://docs.unity3d.com/ScriptReference/<br />MonoBehaviour.OnApplicationPause.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Editor
|
||||
|
||||
| Node | Description |
|
||||
| -------------------- | ------------------------------------------------------------ |
|
||||
| OnDrawGizmos | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnDrawGizmos.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnDrawGizmos.html) |
|
||||
| OnDrawGizmosSelected | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnDrawGizmosSelected.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnDrawGizmosSelected.html) |
|
||||
|
||||
|
||||
|
||||
### Events, GUI
|
||||
|
||||
| Node | Description |
|
||||
| ------------------------ | ------------------------------------------------------------ |
|
||||
| OnBeginDrag | Implements IBeginDragHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IBeginDragHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IBeginDragHandler.html) |
|
||||
| OnButtonClick | Registers to a Button's onClick event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.Button.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Button.html) |
|
||||
| OnCancel | Implements ICancelHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.ICancelHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.ICancelHandler.html) |
|
||||
| OnDeselect | Implements IDeselectHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IDeselectHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IDeselectHandler.html) |
|
||||
| OnDrag | Implements IDragHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IDragHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IDragHandler.html) |
|
||||
| OnDrop | Implements IDropHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IDragHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IDragHandler.html) |
|
||||
| OnDropdownValueChanged | Registers to a Dropdown's onValueChanged event<br /> https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.Dropdown.html |
|
||||
| OnEndDrag | Implements IEndDragHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IEndDragHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IEndDragHandler.html) |
|
||||
| OnGUI | Triggers on MonoBehaviour.OnGUI<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />MonoBehaviour.OnGUI.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/MonoBehaviour.OnGUI.html) |
|
||||
| OnInputFieldEndEdit | Registers to an InputField's onEndEdit event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.InputField.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.InputField.html) |
|
||||
| OnInputFieldValueChanged | Registers to an InputField's onValueChanged event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.InputField.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.InputField.html) |
|
||||
| OnMove | Implements IMoveHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IMoveHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IMoveHandler.html) |
|
||||
| OnPointerClick | Implements IPointerClickHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IPointerClickHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerClickHandler.html) |
|
||||
| OnPointerDown | Implements IPointerDownHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IPointerDownHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerDownHandler.html) |
|
||||
| OnPointerEnter | Implements IPointerEnterHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IPointerEnterHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerEnterHandler.html) |
|
||||
| OnPointerExit | Implements IPointerExitHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IPointerExitHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerExitHandler.html) |
|
||||
| OnPointerUp | Implements IPointerUpHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IPointerUpHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerUpHandler.html) |
|
||||
| OnScroll | Implements IPointerScrollHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.IPointerScrollHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerScrollHandler.html) |
|
||||
| OnScrollbarValueChanged | Registers to a Scrollbar's onValueChanged event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.Scrollbar.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Scrollbar.html) |
|
||||
| OnScrollRectValueChanged | Registers to a ScrollRect's onValueChanged event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.ScrollRect.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.ScrollRect.html) |
|
||||
| OnSelect | Implements ISelectHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.ISelectHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.ISelectHandler.html) |
|
||||
| OnSliderValueChanged | Registers to a Sliders's onValueChanged event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.Slider.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Slider.html) |
|
||||
| OnSubmit | Implements ISubmitHandler<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />EventSystems.ISubmitHandler.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.ISubmitHandler.html) |
|
||||
| OnToggleValueChanged | Registers to a Toggle's onValueChanged event<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />UI.Toggle.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Toggle.html) |
|
||||
|
||||
### Events, Hierarchy
|
||||
|
||||
| Node | Description |
|
||||
| -------------------------- | ------------------------------------------------------------ |
|
||||
| OnTransformChildrenChanged | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTransformChildrenChanged.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTransformChildrenChanged.html) |
|
||||
| OnTransformParentChanged | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTransformParentChanged.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTransformParentChanged.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Input
|
||||
|
||||
| Node | Description |
|
||||
| ----------------- | ------------------------------------------------------------ |
|
||||
| OnButtonInput | On Update, checks Input.GetButtonDown/GetButtonUp/GetButton based on the specified Action type <br />[https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Input.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Input.html). |
|
||||
| OnKeyboardInput | On Update, check Input.GetKeyDown/GetKeyUp/GetKey based on the specified action type<br /> [https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Input.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Input.html) |
|
||||
| OnMouseDown | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseDown.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseDown.html) |
|
||||
| OnMouseDrag | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseDrag.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseDrag.html) |
|
||||
| OnMouseEnter | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseEnter.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseEnter.html) |
|
||||
| OnMouseExit | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseExit.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseExit.html) |
|
||||
| OnMouseInput | [https://docs.unity3d.com/ScriptReference/<br />Input.GetMouseButton.html](https://docs.unity3d.com/ScriptReference/Input.GetMouseButton.html) |
|
||||
| OnMouseOver | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseOver.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseOver.html) |
|
||||
| OnMouseUp | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseUp.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseUp.html) |
|
||||
| OnMouseUpAsButton | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnMouseUpAsButton.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnMouseUpAsButton.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Lifecycle
|
||||
|
||||
| Node | Description |
|
||||
| ----------- | ------------------------------------------------------------ |
|
||||
| FixedUpdate | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.FixedUpdate.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.FixedUpdate.html) |
|
||||
| LateUpdate | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.LateUpdate.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.LateUpdate.html) |
|
||||
| OnDestroy | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnDestroy.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnDestroy.html) |
|
||||
| OnDisable | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnDisable.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnDisable.html) |
|
||||
| OnEnable | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnEnable.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnEnable.html) |
|
||||
| Start | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.Start.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.Start.html) |
|
||||
| Update | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.Update.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.Start.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Navigation
|
||||
|
||||
| Node | Description |
|
||||
| -------------------- | ------------------------------------------------------------ |
|
||||
| OnDestinationReached | Trigger if a NavMeshAgent's remaining distance to its target is less than the provided threshold and either has a current NavMeshPathStatus of PathComplete or requireSuccess is false. <br />[https://docs.unity3d.com/2019.1/Documentation/ScriptReference/<br />AI.NavMeshAgent.html](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/AI.NavMeshAgent.html). |
|
||||
|
||||
|
||||
|
||||
### Events, Physics
|
||||
|
||||
| Node | Description |
|
||||
| ----------------------- | ------------------------------------------------------------ |
|
||||
| OnCollisionEnter | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnCollisionEnter.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html) |
|
||||
| OnCollisionExit | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnCollisionExit.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnCollisionExit.html) |
|
||||
| OnCollisionStay | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnCollisionStay.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnCollisionStay.html) |
|
||||
| OnControllerColliderHit | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnControllerColliderHit.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnControllerColliderHit.html) |
|
||||
| OnJointBreak | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnJointBreak.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnJointBreak.html) |
|
||||
| OnParticleCollision | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnParticleCollision.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnParticleCollision.html) |
|
||||
| OnTriggerEnter | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTriggerEnter.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter.html) |
|
||||
| OnTriggerExit | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTriggerExit.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTriggerExit.html) |
|
||||
| OnTriggerStay | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTriggerStay.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTriggerStay.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Physics 2D
|
||||
|
||||
| Node | Description |
|
||||
| ------------------------- | ------------------------------------------------------------ |
|
||||
| OnCollisionEnter2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnCollisionEnter2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html) |
|
||||
| OnCollisionExit2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnCollisionExit2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnCollisionExit2D.html) |
|
||||
| OnCollisionStay2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnCollisionStay2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnCollisionStay2D.html) |
|
||||
| OnControllerColliderHit2D | [https://docs.unity3d.com/ScriptReference/<br />MonoBehaviour.OnControllerColliderHit.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnControllerColliderHit.html) |
|
||||
| OnJointBreak2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnJointBreak2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnJointBreak2D.html) |
|
||||
| OnParticleCollision2D | [https://docs.unity3d.com/ScriptReference/<br />MonoBehaviour.OnParticleCollision.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleCollision.html) |
|
||||
| OnTriggerEnter2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTriggerEnter2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter2D.html) |
|
||||
| OnTriggerExit2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTriggerExit2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTriggerExit2D.html) |
|
||||
| OnTriggerStay2D | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnTriggerStay2D.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnTriggerStay2D.html) |
|
||||
|
||||
|
||||
|
||||
### Events, Rendering
|
||||
|
||||
| Node | Description |
|
||||
| ----------------- | ------------------------------------------------------------ |
|
||||
| OnBecameInvisible | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnBecameInvisible.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnBecameInvisible.html) |
|
||||
| OnBecameVisible | [https://docs.unity3d.com/2021.1/Documentation/ScriptReference/<br />MonoBehaviour.OnBecameVisible.html](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/MonoBehaviour.OnBecameVisible.html) |
|
||||
|
||||
|
||||
|
||||
### Events, State
|
||||
|
||||
| Node | Description |
|
||||
| ------------ | ------------------------ |
|
||||
| OnEnterState | When a state is entered. |
|
||||
| OnExitState | When a state is exited. |
|
||||
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
# Known Issues: Unity Editor script functions
|
||||
|
||||
If you use nodes that use Unity Editor script functions in any of the Visual Scripting graphs in your project, it causes errors when you try to build your project.
|
||||
|
||||
## Cause of the build errors
|
||||
|
||||
Unity Visual Scripting (UVS) doesn't support preprocessor directives, so the use of Unity Editor script functions within graphs isn't possible. However, these functions can appear as node options within UVS because UVS uses C# reflection to generate nodes for your project based on your included assemblies. If you add one of these Unity Editor script nodes to a graph that's used in a build of your project, Unity generates an error when it attempts to build the project. An error message of the following format is displayed in the Unity Console:
|
||||
|
||||
`/<ProjectPath>/<CSharpFile>.cs: error CS0103: The name '<MissingApiName>' does not exist in the current context.`
|
||||
|
||||
The following code sample is an example of preprocessor directives for Unity Editor scripts :
|
||||
```
|
||||
#if UNITY_EDITOR
|
||||
public static List<Type> GetAllVolumeComponents()
|
||||
{
|
||||
// TypeCache is only accessible in UnityEditor.
|
||||
// If you instantiate a GetAllVolumeComponents node in a graph
|
||||
// it prevents the project from being built.
|
||||
return TypeCache.GetTypesDerivedFrom<VolumeComponent>().ToList();
|
||||
}
|
||||
#endif
|
||||
```
|
||||
|
||||
## Find flagged packages
|
||||
|
||||
Packages that contain editor scripts are flagged with a warning icon in the Node Library section of the Visual Scripting tab in the Project Settings window.
|
||||
|
||||
To find the affected packages, do the following:
|
||||
|
||||
1. Go to **Edit** > **Project Settings**.
|
||||
1. In the Project Settings window, select the **Visual Scripting** tab.
|
||||
1. On the Visual Scripting tab expand the **Node Library** section. </br>
|
||||
A yellow warning flag is displayed next to any affected packages as shown in the following screenshot.
|
||||

|
||||
|
||||
## Resolution
|
||||
|
||||
To resolve this issue, go through your graphs and replace nodes that correspond to the API mentioned in the error message until you find the error no longer occurs.
|
@ -0,0 +1,133 @@
|
||||
# Events node
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Scripting nodes listen for events. They are the starting point for all scripts and appear as special green nodes in graphs.
|
||||
|
||||
There are many kinds of events, grouped in sub-categories under the root Events category **(fuzzy finder** > **Events**).
|
||||
|
||||
Two simple common events are Start and Update, both located under **Lifecycle**.
|
||||
|
||||
* Start is called once when the graph or event handler is first created.
|
||||
* Update is called at every frame while the graph or event handler is active.
|
||||
|
||||
New script machines start with both these events by default.
|
||||
|
||||
|
||||

|
||||
|
||||
## Inputs & Outputs
|
||||
|
||||
|
||||
All events have a single Trigger control output that starts the script when they are triggered.
|
||||
|
||||
Value inputs are options that influence when the event is triggered. For example, some events have a Target setting that determines which object is listening to the event. Most often, you'll leave this setting at its default value of Self.
|
||||
|
||||
The value outputs on events are arguments that are passed from the event, giving you more information about what actually happened. For example, on the On Trigger Enter event, the other collider that is involved in the collision is an output.
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## Custom Events
|
||||
|
||||
|
||||
There is a special type of event, the Custom Event that triggers custom events across graphs, along with their custom arguments.
|
||||
|
||||
For example, to create a custom event called On Damage that gets called so the character loses health, the event should have one integer argument that indicates the amount of damage to inflict. Listen to the event by creating a Custom Event node (under Events). Set the name to On Damage. The set the argument count, below the name, to 1.
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> Indices are zero-based, so the first argument is labeled Arg. 0.
|
||||
|
||||
To trigger the event from elsewhere, use the Trigger Custom Event node, located right under the Custom Event node in the fuzzy finder. Enter the name of the event exactly as it is sensitive to case and whitespace.
|
||||
|
||||
For example, to create a script machine on a boulder that could hit the player, use the force of the impact as the damage.
|
||||
|
||||
|
||||

|
||||
|
||||
The collider that hit with the boulder is the target of our trigger; the On Damage event is triggered on all machines attached to that collider. Use the damage value to subtract health from the receiver object.
|
||||
|
||||
|
||||

|
||||
|
||||
Custom events do not require a receiver and do not cause an error if there isn't a listener to handle them.
|
||||
|
||||
## Animation Events
|
||||
|
||||
Use animation events to trigger Bolt graphs when you reach a certain point in your animation. Select an object with a machine and an animator. Then, from the animation window, add an animation event.
|
||||
|
||||
|
||||

|
||||
|
||||
With the event selected, choose TriggerAnimationEvent as the function from the inspector.
|
||||
|
||||
|
||||

|
||||
|
||||
Use any parameter from the inspector.
|
||||
|
||||
|
||||

|
||||
|
||||
In your script graph, add an Animation Event node (under **Events** >**Animation**).
|
||||
|
||||
There are two types of events:
|
||||
|
||||
- a global animation event, and
|
||||
- a named animation event.
|
||||
|
||||
|
||||

|
||||
|
||||
The difference is that the first type listens to all animation events on the object and return the string parameter. The second type's trigger is the string parameter that is equal to the specified name input.
|
||||
|
||||
## Unity Events
|
||||
|
||||
Use Unity Events to trigger events that have been setup from the inspector. These are commonly found in GUI components like buttons, but [they can also be created in your custom scripts](https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html).
|
||||
|
||||
|
||||
Configure them by selecting an object with a machine and select the Trigger Unity Event method. In the string field, type the event name to listen to in the graph and in the graph, add a UnityEvent node with a matching name.
|
||||
|
||||
|
||||

|
||||
|
||||
Additional arguments are not supported on Unity events.
|
||||
|
||||
## Events API
|
||||
|
||||
Visual scripting provides a simple API to trigger custom events from C# script.
|
||||
|
||||
Add the following usings to your C# script to access the API.
|
||||
|
||||
```
|
||||
using Unity.VisualScripting
|
||||
```
|
||||
|
||||
### Triggering API
|
||||
|
||||
A single method call is needed to trigger a custom event. Pass as many arguments as required.
|
||||
|
||||
```
|
||||
CustomEvent.Trigger(targetGameObject, argument1, argument2, ...)
|
||||
```
|
||||
|
||||
For example, this custom event node:
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Can be triggered with this line of code.
|
||||
|
||||
|
||||
|
||||
```
|
||||
CustomEvent.Trigger(enemy, "Damage", 30);
|
||||
```
|
||||
|
@ -0,0 +1,36 @@
|
||||
# Events API
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
|
||||
Visual scripting provides a simple API to trigger custom events from C# script.
|
||||
|
||||
## Usings
|
||||
|
||||
Add the following usings to your C# script to access the API.
|
||||
|
||||
```
|
||||
using Unity.VisualScripting;
|
||||
```
|
||||
|
||||
## Triggering
|
||||
|
||||
A single method call is needed to trigger a custom event. Pass as many arguments as required.
|
||||
|
||||
```
|
||||
CustomEvent.Trigger(targetGameObject, argument1, argument2, ...)
|
||||
```
|
||||
|
||||
For example, this custom event node:
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Can be triggered with this line of code.
|
||||
|
||||
```
|
||||
CustomEvent.Trigger(enemy, "On Damage", 30);
|
||||
```
|
||||
|
@ -0,0 +1,108 @@
|
||||
# Formula node
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Formula is a powerful node that evaluates logical and mathematical expressions directly via a textual Formula and a list of Arguments.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Due to the binary tree traversal overhead (despite caching attempts), performance in using the formula node is significantly slower than using the operator nodes individually. It is preferable to avoid using this node at every frame.
|
||||
|
||||
Although a formula can return either a boolean for logic, or a number for math, formulas can return any type of value.
|
||||
|
||||

|
||||
|
||||
The first text field in the header is the formula itself.
|
||||
|
||||
The second text field is the number of arguments. It's set to 2 by default, giving us A and B as inputs. Formulas can have up to 10 arguments, which are always ordered alphabetically. If more are required, they are called B, C, D, E, and so forth.
|
||||
|
||||
For example, this formula returns a boolean indicating:
|
||||
|
||||
- whether, at a minimum, 10 seconds have elapsed since the start of the game and
|
||||
- the current object's name is Player.
|
||||
|
||||

|
||||
|
||||
## Arguments
|
||||
|
||||
### Variable Names
|
||||
|
||||
Variable names can be directly used in the formula. For example, a graph variable named health can return a boolean just by typing the formula health > 50. The argument names are evaluated in the following order of priority:
|
||||
|
||||
1. Alphabetical argument names (a - z)
|
||||
2. Graph variable names
|
||||
3. Object variable names
|
||||
4. Scene variable names
|
||||
5. Application variable names
|
||||
6. Saved variable names
|
||||
|
||||
### Properties and Methods
|
||||
|
||||
Retrieve the value of a property on an argument or variable by using the \[arg.prop\] notation. For example, if position is a Vector 3 object variable, check if it is equal to zero with: \[position.x\] = 0. Get the return value of parameterless methods with the \[arg.Method()\] notation.
|
||||
|
||||
Note: Accessing properties and methods is not guaranteed to be compatible with AOT platforms, because the AOT pre-build cannot generate stubs for members that are only accessed by name.
|
||||
|
||||
### Literals
|
||||
|
||||
Use the following literals for assigning fixed values.
|
||||
|
||||
| Literal | Description | Example |
|
||||
|-------------------|--------------------------------------|----------------|
|
||||
| Number | An integer or float. | 3.5 |
|
||||
| String | A piece of text between apostrophes. | "Hello World!" |
|
||||
| Boolean | A boolean value. | true, false |
|
||||
| Null | The null constant. | a != null |
|
||||
| Delta Time | The Unity frame delta time. | 30 \* dt |
|
||||
| Invert Delta Time | The inverse of the delta time. | 30 / second |
|
||||
|
||||
### Operators
|
||||
|
||||
|
||||
Every common logical and mathematical operator can be used in formulas, as well as the ones defined through custom operator overloading in script.
|
||||
|
||||
| Operator | Operation | Rank | Result | Example |
|
||||
|------------------|--------------------|---------|-------------------------------------------------------------------------|----------------------------------|
|
||||
| not, ! | Logical Negation | Unary | The opposite of the operand. | not true |
|
||||
| \- | Numerical Negation | Unary | The negative of the operand. | -5 |
|
||||
| and, && | Logical And | Binary | True if both operands are true. | (a \< 5) and (b \> 3) |
|
||||
| or, \|\| | Logical Or | Binary | True if either operand is true | (a \< 5) or (b \> 3) |
|
||||
| =, == | Equality | Binary | True if the two operands are equal. | a = b |
|
||||
| !=, \<\> | Inequality | Binary | True if the two operands are not equal. | a != b |
|
||||
| \<, \<=, \>, \>= | Numeric Comparison | Binary | The result of a numeric comparison | a \>= 10 |
|
||||
| \+ | Addition | Binary | The sum of the two operands. | a + 5 |
|
||||
| \- | Subtraction | Binary | The difference between the two operands. | b - 3 |
|
||||
| \* | Multiplication | Binary | The product of the two operands. | 12 \* a |
|
||||
| / | Division | Binary | The quotient of the two operands. | b / 2 |
|
||||
| % | Modulo | Binary | The remainder of the division of the two operands. | a % 2 |
|
||||
| ?: | If | Ternary | The left operand if the condition is true, otherwise the right operand. | (health \> 0) ? "Alive" : "Dead" |
|
||||
|
||||
All common bitwise operators like \~ and >> are also supported.
|
||||
|
||||
### Functions
|
||||
|
||||
You can also use any function from the following table.
|
||||
|
||||
| Name | Result | Example |
|
||||
|----------|------------------------------------------------------------------------------|-----------------|
|
||||
| abs | The absolute value of a specified number. | abs(-1) |
|
||||
| acos | The angle whose cosine is the specified number. | acos(1) |
|
||||
| asin | The angle whose sine is the specified number. | asin(0) |
|
||||
| atan | The angle whose tangent is the specified number. | atan(0) |
|
||||
| ceiling | The smallest integer greater than or equal to the specified number. | ceiling(1.5) |
|
||||
| cos | The cosine of the specified angle. | cos(0) |
|
||||
| exp | e raised to the specified power. | exp(0) |
|
||||
| floor | The largest integer less than or equal to the specified number. | floor(1.5) |
|
||||
| log | The logarithm of a specified number. | log(1, 10) |
|
||||
| log10 | The base 10 logarithm of a specified number. | log10(1) |
|
||||
| max | The larger of two specified numbers. | max(1, 2) |
|
||||
| min | The smaller of two numbers. | min(1, 2) |
|
||||
| pow | A specified number raised to the specified power. | pow(3, 2) |
|
||||
| round | Rounds a value to the nearest integer or specified number of decimal places. | round(3.222, 2) |
|
||||
| sign | 1 if the number is positive, -1 is if it negative. | sign(-10) |
|
||||
| sin | The sine of the specified angle. | sin(0) |
|
||||
| sqrt | The square root of a specified number. | sqrt(4) |
|
||||
| tan | The tangent of the specified angle. | tan(0) |
|
||||
| truncate | The integral part of a number. | truncate(1.7) |
|
||||
| v2 | Creates a 2D vector. | v2(0, 0) |
|
||||
| v3 | Creates a 3D vector. | v3(0, 0, 0) |
|
||||
| v4 | Creates a 4D vector. | v4(0, 0, 0, 0) |
|
@ -0,0 +1,48 @@
|
||||
# Script Machines and State Machines
|
||||
|
||||
A Script Machine is a GameObject component that lets you use a Script Graph in an application. You can't use a Script Graph unless it's attached to a Script Machine. For more information on components, see [Introduction to components](https://docs.unity3d.com/Manual/Components.html) in the Unity User Manual.
|
||||
|
||||
Script Machines can either link to a graph asset, or they can contain an embedded Script Graph asset.
|
||||
|
||||

|
||||
|
||||
A State Machine is the same as a Script Machine, except it contains a State Graph.
|
||||
|
||||

|
||||
|
||||
For more information on the difference between a Script Graph and a State Graph, see [Graphs](vs-graph-types.md).
|
||||
|
||||
Add a Script Machine or State Machine component to a GameObject and Visual Scripting automatically adds a Variables component. The Variables component holds any Object variables that you define in a Script Graph or State Graph attached to the GameObject. For more information on variables, see [Variables](vs-variables.md).
|
||||
|
||||
For more information on how to add a Script Machine or State Machine to a GameObject and attach a graph file, see [Attach a graph file to a Script Machine or State Machine](vs-attach-graph-machine.md)
|
||||
|
||||
## Source types
|
||||
|
||||
Script Machines and State Machines have two options for their Source: a graph file (**Graph**), or an embedded asset (**Embed**).
|
||||
|
||||
Set the **Source** for a Script Machine or State Machine at any time. If you switch the Source from **Graph** to **Embed**, the graph file still exists as a separate file from the State Machine or Script Machine inside of your project.
|
||||
|
||||
> [!CAUTION]
|
||||
> If you switch your Source from **Embed** to **Graph**, you will lose the embedded graph asset. You can copy the nodes from an embedded graph to a graph asset to avoid data loss.
|
||||
|
||||
Other features of Visual Scripting, such as transitions, Super States, and Subgraphs, also have these source type options.
|
||||
|
||||
### The Graph source type
|
||||
|
||||
Use the **Graph** source type to make your graphs faster to load and easier to maintain. Any changes made to a graph file apply to every Script Machine or State Machine that links to that graph file, even if those GameObjects don't use the same Prefab.
|
||||
|
||||
To use the same graph across multiple GameObjects, use a **Graph** source type. You might encounter some situations where an embedded graph works best.
|
||||
|
||||
### The Embed source type
|
||||
|
||||
An **Embed** graph exists only in the scene where it's created, if it isn't attached to a Prefab. This can cause problems with source control systems.
|
||||
|
||||
If you delete a GameObject with an **Embed** graph asset, you will lose your graph. Changes made to an embedded graph aren't saved while the Editor is in Play mode.
|
||||
|
||||
Use the **Embed** source type if:
|
||||
|
||||
- You need references to GameObjects from the current scene in the graph and the graph isn't on a Prefab.
|
||||
- The graph is on a Prefab that you plan to instantiate in the application during runtime.
|
||||
- You only need to use the logic in the graph once in the application.
|
||||
|
||||
You can't reuse an embedded graph across multiple GameObjects unless the graph is on a Prefab. An embed graph only exists on the Script Machine or State Machine where you created it. This means you can share the graph across instances of a Prefab, but not on more than one GameObject. For more information about Prefabs, see [Prefabs](https://docs.unity3d.com/Manual/Prefabs.html) in the User Manual.
|
@ -0,0 +1,43 @@
|
||||
# Graphs
|
||||
|
||||
A graph is a Visual Scripting asset that contains a visual representation of logic in an application.
|
||||
|
||||
Visual Scripting has two different types of graphs: Script Graphs and State Graphs. You can use either graph type in specific situations to define and change how GameObjects in an application behave. Script Graphs and State Graphs must be attached to a Script Machine or State Machine to be used in a project. For more information on Script Machines and State Machines, see [Script Machines and State Machines](vs-graph-machine-types.md).
|
||||
|
||||
## Script Graphs
|
||||
|
||||
Script Graphs control and connect specific actions and values. The actions in a Script Graph happen in a specific order. Actions can happen every frame, or when a specific event occurs.
|
||||
|
||||

|
||||
|
||||
Visual Scripting represents the actions in a Script Graph through [nodes](vs-nodes.md). Connect nodes together with edges to tell your application what to do, and in what order.
|
||||
|
||||
Script Graphs can access a large collection of nodes, which correspond to different features and functionality in the Unity Editor. Access these nodes through [the fuzzy finder](vs-interface-overview.md#the-fuzzy-finder).
|
||||
|
||||
Script Graphs define the specifics of what a GameObject does while your application runs.
|
||||
|
||||
## State Graphs
|
||||
|
||||
A State Graph has states and gives the logic for when your application moves between states, through connections called transitions. Use State Graphs to design AI behavior or define scene and level structures.
|
||||
|
||||
A state is any set of behaviors that you want a GameObject to perform, represented as a Script Graph. Visual Scripting represents states in State Graphs through State nodes. A State node can link to a Script Graph with logic for your application to follow, or give another State Graph with additional transitions and State nodes.
|
||||
|
||||

|
||||
|
||||
States and transitions in a State Graph tell your application when to change its behavior, based on an event or after it fulfills a condition.
|
||||
|
||||
For example, you might have an enemy character with Patrol and Chase states. The enemy character's actions can change from the actions in the Script Graph for the Patrol state to the actions for the Chase state after it detects the player character. The detection event for the enemy character triggers the transition between the two states.
|
||||
|
||||
State Graphs don't use the fuzzy finder. They use a specific set of State nodes, which are in the Visual Scripting context menu:
|
||||
|
||||
- Script States contain a Script Graph. When an application triggers a Script State, Visual Scripting runs the logic in a Script State's attached Script Graph. Script States use On Enter State Event, On Update Event, and On Exit State Event nodes to control logic based on the current state.
|
||||
|
||||
- Super States contain another, nested State Graph. A Super State can help you better organize a State Graph, and reuse states and transitions across multiple graphs.
|
||||
|
||||
- Any States serve as a placeholder for any other state in a State Graph. You can use an Any State node and create a single transition to a new state, rather than create multiple transitions from other states.
|
||||
|
||||
- Transitions connect Script States, Any States, and Super States. Transitions contain Script Graphs that tell your application when to switch from one state to the next. For more information, see [Transitions](vs-transitions.md).
|
||||
|
||||
You can set any Script State node or Super State node as a Start State. Any state marked as a Start State is automatically active when Visual Scripting runs a State Graph. You can also have multiple Start States in a single graph. The Super State, Start, and Script State nodes in the following example are all Start States.
|
||||
|
||||

|
@ -0,0 +1,84 @@
|
||||
# Create node groups
|
||||
|
||||
You can organize the nodes in your Script Graphs and State Graphs with node groups.
|
||||
|
||||

|
||||
|
||||
## Create a new group
|
||||
|
||||
To create a new group:
|
||||
|
||||
1. [Open the graph](vs-open-graph-edit.md) where you want to create a new group.
|
||||
|
||||
1. In an empty area of the Graph Editor, Ctrl+click (macOS: Cmd+click) and drag to create a selection.
|
||||
|
||||
1. Release the mouse to create the group.
|
||||
|
||||
After you create a group, you can:
|
||||
|
||||
- [Change the group name](#change-a-group-name)
|
||||
- [Add a comment to the group](#add-a-comment-to-a-group)
|
||||
- [Change the color of the group](#change-the-color-of-a-group)
|
||||
- [Resize the group](#resize-a-group)
|
||||
- [Move the group](#move-a-group)
|
||||
|
||||
## Change a group name
|
||||
|
||||
To change the name of the group in your graph:
|
||||
|
||||
2. In the group header, click **Group**.
|
||||
|
||||
1. Enter a new name for the group.
|
||||
|
||||
1. Press **Enter** to save your changes.
|
||||
|
||||
## Add a comment to a group
|
||||
|
||||
To add a comment to a group in a graph:
|
||||
|
||||
1. Select the group where you want to add a comment.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the **(Comment)** field in the Graph Inspector, enter comments or information about the group.
|
||||
|
||||
> [!NOTE]
|
||||
> Group comments are only visible in the Graph Inspector. To add comments to a graph that are always visible, use a [Sticky Note](vs-sticky-notes.md).
|
||||
|
||||
## Change the color of a group
|
||||
|
||||
To change the color of a group in a graph:
|
||||
|
||||
1. Select the group you want to edit.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, select the **Color** field.
|
||||
|
||||
1. Select a new color for your group through one of the following methods:
|
||||
|
||||
- Use the color picker.
|
||||
- Use the sliders or RGBA value fields.
|
||||
- Enter a hexadecimal color value.
|
||||
- Select the eyedropper icon and select a color from anywhere on your screen.
|
||||
|
||||
## Resize a group
|
||||
|
||||
To resize a group in a graph:
|
||||
|
||||
1. Click and drag from any edge or corner on the group.
|
||||
|
||||
## Move a group
|
||||
|
||||
To move a group and its nodes:
|
||||
|
||||
1. Click and drag the group's header to a new location in the Graph Editor.
|
||||
|
||||
> [!NOTE]
|
||||
> You can also move a group without moving any of the nodes inside, but the required input changes based on your chosen control scheme. For more information, see [Choose a control scheme](vs-control-schemes.md)
|
||||
|
||||
## Next steps
|
||||
|
||||
After you've created a node group, you can [add nodes to your Script Graph](vs-add-node-to-graph.md), [create and add variables](vs-add-variable-graph.md), or [add a Subgraph](vs-nesting-add-subgraph.md).
|
||||
|
||||
You can also add a [Sticky Note](vs-sticky-notes.md) to add comments to a graph.
|
@ -0,0 +1,39 @@
|
||||
# Input Event nodes
|
||||
|
||||
Input nodes are an Event node type that can read input from Unity's [Input Manager](https://docs.unity3d.com/Manual/class-InputManager.html) or [Input System package](https://docs.unity3d.com/Packages/com.unity.inputsystem@latest) for use in a Script Graph.
|
||||
|
||||
For more information about how to read and capture input in Visual Scripting, see [Capture user input in an application](vs-capture-player-input.md).
|
||||
|
||||
## Input System package nodes
|
||||
|
||||
The following nodes read and interact with Events from the Input System package:
|
||||
|
||||
| **Node** | **Description** |
|
||||
| :------ | :--------------- |
|
||||
| [**On Input System Event Button**](vs-nodes-events-input-system-button.md) | The On Input System Event Button node listens for a specific Input Action from a Player Input component. It doesn't send or read any other data. |
|
||||
| [**On Input System Event Float**](vs-nodes-events-input-system-float.md) | The On Input System Event Float node listens for a specific Input Action from a Player Input component. The node can output a **single float value**. |
|
||||
| [**On Input System Event Vector 2**](vs-nodes-events-input-system-vector2.md) | The On Input System Event Vector 2 node listens for a specific Input Action from a Player Input component. The node can output **two values as a Vector 2**. |
|
||||
|
||||
## Input Manager nodes
|
||||
|
||||
The following nodes read and interact with Events from Unity's Input Manager:
|
||||
|
||||
| **Node** | **Description** |
|
||||
| :------ | :--------------- |
|
||||
| [**On Button Input**](vs-nodes-events-on-button-input.md) | The On Button Input node listens for a specified action on a virtual button from your Input Manager configuration. |
|
||||
| [**On Keyboard Input**](vs-nodes-events-on-keyboard-input.md) | The On Keyboard Input node listens for a specified action on a keyboard key. |
|
||||
| [**On Mouse Down**](vs-nodes-events-on-mouse-down.md) | The On Mouse Down node listens for a mouse click action on a specific GameObject in your application. |
|
||||
| [**On Mouse Drag**](vs-nodes-events-on-mouse-drag.md) | The On Mouse Drag node listens for a mouse click and hold on a specific GameObject in your application. It triggers the next node connected to it as long as the mouse button is held down on that GameObject. |
|
||||
| [**On Mouse Enter**](vs-nodes-events-on-mouse-enter.md) | The On Mouse Enter node listens for the user's mouse pointer location to enter the Collider of a specified GameObject. When the mouse enters the Collider or GUI element, the node triggers the next node connected to it. |
|
||||
| [**On Mouse Exit**](vs-nodes-events-on-mouse-exit.md) | The On Mouse Exit node listens for the user's mouse pointer location to exit the Collider of a specified GameObject. When the mouse exits the Collider or GUI element, the node triggers the next node connected to it. |
|
||||
| [**On Mouse Input**](vs-nodes-events-on-mouse-input.md)| The On Mouse Input node listens for a specific action on a user's mouse. The action doesn't need to happen on a specific GameObject's Collider. |
|
||||
| [**On Mouse Over**](vs-nodes-events-on-mouse-over.md) | The On Mouse Over node listens for a user's mouse to land over a specified GameObject's Collider. While the user's mouse is over the Collider, it triggers the next node connected to it once every frame. |
|
||||
| [**On Mouse Up As Button**](vs-nodes-events-on-mouse-up-button.md) | The On Mouse Up As Button node listens for a user to release their mouse button after they click a Collider in your application. To trigger the On Mouse Up As Button node, the user must release their mouse button over the same Collider they clicked. |
|
||||
| [**On Mouse Up**](vs-nodes-events-on-mouse-up.md) | The On Mouse Up node listens for a user to release their mouse button after they click a Collider in your application. The user can release their mouse button anywhere in your application to trigger the On Mouse Up node. |
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Capturing input in your application](vs-capture-player-input.md)
|
||||
- [Capture input using the Input System package](vs-capturing-player-inputs-new.md)
|
||||
- [Capture input using the Input Manager](vs-capturing-player-inputs-old.md)
|
||||
|
@ -0,0 +1,187 @@
|
||||
# The interface
|
||||
|
||||
Visual Scripting's main window is the Graph window.
|
||||
|
||||

|
||||
|
||||
The Graph window has five main elements:
|
||||
|
||||
- The [**Graph Editor**](#the-graph-editor), where you create, arrange, and connect nodes.
|
||||
- The [**fuzzy finder**](#the-fuzzy-finder), which you can use to find nodes and add them to your graph.
|
||||
- The [**Graph toolbar**](#the-graph-toolbar), where you can change settings specific to your view in the Graph Editor and perform some common layout operations.
|
||||
- The [**Graph Inspector**](#the-graph-inspector), where you can view detailed information about your nodes and configure additional settings for your graph.
|
||||
- The [**Blackboard**](#the-blackboard), where you can define and edit variables to use in your graphs.
|
||||
|
||||
## The Graph Editor
|
||||
|
||||
The Graph Editor is the center editing area of the Graph window.
|
||||
|
||||

|
||||
|
||||
You can use the Graph Editor to create your Visual Scripting graphs. You can create nodes and connect them with edges.
|
||||
|
||||
You can change some default shortcuts and behaviors in the Graph Editor through your control scheme. For more information on the available control schemes in Visual Scripting, see [Choose a control scheme](vs-control-schemes.md).
|
||||
|
||||
## The fuzzy finder
|
||||
|
||||
The fuzzy finder is a searchable menu that lists every node available in Visual Scripting. Right-click anywhere in the Graph Editor to open the fuzzy finder.
|
||||
|
||||

|
||||
|
||||
Search for a node by name with the Search bar, or open a category from the list to view related nodes. For example, nodes related to the creation or manipulation of variables are in the **Variables** category.
|
||||
|
||||
You can add new nodes to Visual Scripting from your own code, from other packages, or from other Unity features. For more information on how to add nodes to the fuzzy finder, see [Configure project settings](vs-configuration.md).
|
||||
|
||||
## The Graph toolbar
|
||||
|
||||
The Graph toolbar lets you display or hide the Graph Inspector and Blackboard. The Graph toolbar also includes a breadcrumb trail for navigation through nested graphs that displays your current location. Select a graph from the trail to return to that graph file.
|
||||
|
||||
You can also configure some additional settings that control how nodes display in the Graph Editor.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Property</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Lock</strong></td>
|
||||
<td colspan="2">Lock the current Script Graph or State Graph to the Graph window. Visual Scripting keeps the current graph open, even if you select another GameObject with a graph file in the <a href="https://docs.unity3d.com/Manual/Hierarchy.html">Hierarchy window</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Graph Inspector</strong></td>
|
||||
<td colspan="2">Display or hide <a href="#the-graph-inspector">the Graph Inspector</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Blackboard</strong></td>
|
||||
<td colspan="2">Display or hide <a href="#the-blackboard">the Blackboard</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Breadcrumb Location</strong></td>
|
||||
<td colspan="2">Displays the name of the current graph. If you open a <a href="vs-nesting-subgraphs-state-units.md">Subgraph or State Unit</a>, or a <a href="vs-graph-types.md#state-graphs">State node</a> inside a State Graph, use the breadcrumbs to navigate back to the parent graph.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Zoom</strong></td>
|
||||
<td colspan="2">Set a zoom level for your view of the Graph Editor.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Relations</strong></td>
|
||||
<td colspan="2">Enable <strong>Relations</strong> to display inner flow connections for Script Graph nodes. For example, on a standard <code>Multiply</code> node, the <strong>Relations</strong> setting draws a line from each input port that merges into a single line on the output port. The lines display the flow of data inside the node. <br/>Disable <strong>Relations</strong> to hide these inner connections.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Values</strong></td>
|
||||
<td colspan="2">Enable <strong>Values</strong> to display the input and output values sent between nodes while the Unity Editor is in Play mode. This can make it easier to debug your scripts. <br/>Disable <strong>Values</strong> to hide input and output values while in Play mode. <br/>For more information on Play mode, see <a href="https://docs.unity3d.com/Manual/GameView.html">The Game view</a> in the Unity User Manual. <div class="NOTE"><h5>NOTE</h5><p>This setting corresponds to the <strong>Show Connection Values</strong> setting in the Preferences window for Visual Scripting. For more information on this preference, see <a href="vs-set-preferences.md#script-graphs-preferences">Configure your preferences</a>.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Dim</strong></td>
|
||||
<td colspan="2">Enable <strong>Dim</strong> to dim any nodes in the Graph Editor that aren't yet connected to the control flow in your graph. The <strong>Dim</strong> setting provides you with a visual cue that a node isn't used in the current configuration of your graph. <br/>Disable <strong>Dim</strong> to display all nodes as active regardless of their connection state. <div class="NOTE"><h5>NOTE</h5><p>This setting corresponds to the <strong>Dim Inactive Nodes</strong> setting in the Preferences window for Visual Scripting. For more information on this preference, see <a href="vs-set-preferences.md#core-preferences">Configure your preferences</a>.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Carry</strong></td>
|
||||
<td colspan="2">Enable <strong>Carry</strong> to move all connected child nodes when you move a parent node. Disable <strong>Carry</strong> to only move the currently selected node.<div class="NOTE"><h5>NOTE</h5><p>This setting corresponds to the <strong>Carry Children</strong> setting in the Preferences window for Visual Scripting. For more information on this preference, see <a href="vs-set-preferences.md#core-preferences">Configure your preferences</a>.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="7"><strong>Align</strong></td>
|
||||
<td colspan="2">Choose an alignment option to align any nodes in your current selection.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Align Left Edges</strong></td>
|
||||
<td>Align all nodes in the selection based on their left edge.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Align Centers</strong></td>
|
||||
<td>Align all nodes in the selection based on their vertical centers.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Align Right Edges</strong></td>
|
||||
<td>Align all nodes in the selection based on their right edges.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Align Top Edges</strong></td>
|
||||
<td>Align all nodes in the selection based on their top edges.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Align Middles</strong></td>
|
||||
<td>Align all nodes in the selection based on their horizontal middles.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Align Bottom Edges</strong></td>
|
||||
<td>Align all nodes in the selection based on their bottom edges.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="9"><strong>Distribute</strong></td>
|
||||
<td colspan="2">Choose a distribution option to evenly distribute space between any nodes in your current selection.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Left Edges</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal distance between the left edges of each node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Centers</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal distance between the vertical centers of each node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Right Edges</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal distance between the right edges of each node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Horizontal Gaps</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal-sized horizontal gap between each node. This distribution affects the space between the left and right edges of nodes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Top Edges</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal distance between the top edges of each node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Middles</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal distance between the horizontal middles of each node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Bottom Edges</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal distance between the bottom edges of each node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Distribute Vertical Gaps</strong></td>
|
||||
<td>Distribute all nodes in the selection to leave an equal-sized vertical gap between each node. This distribution affects the space between the top and bottom edges of nodes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Overview</strong></td>
|
||||
<td colspan="2">Select <strong>Overview</strong> to automatically pan and zoom to fit all elements of your current graph within the Graph Editor.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Full Screen</strong></td>
|
||||
<td colspan="2">Select <strong>Full Screen</strong> when the Graph window is docked in the Unity Editor to maximize the Graph window to the full size of the Editor window.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Your Visual Scripting preferences can change some settings in the Graph toolbar or change how these settings behave. For example, you can control how fast the Graph Editor zooms in and out when you set a zoom level. For more information, see [Configure your preferences](vs-set-preferences.md).
|
||||
|
||||
## The Graph Inspector
|
||||
|
||||
The Graph Inspector provides additional information about an open graph, or about any node you select in the Graph Editor.
|
||||
|
||||

|
||||
|
||||
If a node requires additional configuration, you can use the Graph Inspector to set these values.
|
||||
|
||||
To display or hide the Graph Inspector, select **Graph Inspector** () from the toolbar.
|
||||
|
||||
To move the Graph Inspector to the other side of the Graph window, select either **Dock Right** () or **Dock Left** ().
|
||||
|
||||
## The Blackboard
|
||||
|
||||
The Blackboard provides options to configure and manage variables in a graph. The Blackboard divides variables into five distinct scopes, across five tabs: **Graph**, **Object**, **Scene**, **App**, and **Saved**.
|
||||
|
||||

|
||||
|
||||
For more information on the available variable scopes in Visual Scripting, see [Variables](vs-variables.md).
|
||||
|
||||
To display or hide the Blackboard, select **Blackboard** () from the toolbar.
|
||||
|
||||
To move the Blackboard to the other side of the Graph window, select either **Dock Right** () or **Dock Left** ().
|
||||
|
@ -0,0 +1,41 @@
|
||||
# Live edit during runtime
|
||||
|
||||
Live editing in visual scripting goes beyond adjusting values in real-time. Live editing also includes the ability to add and remove nodes as well as connectors; you can code while the game is playing and immediately affect the gameplay.
|
||||
|
||||
Remember that:
|
||||
|
||||
- Changes you make to embed graphs are **reverted** when you exit play mode; they live inside components.
|
||||
- Changes you make to graphs are **saved** when you exit play mode; they live inside assets.
|
||||
- Graph variables are saved when not in an embed graph.
|
||||
- The following variables are not saved:
|
||||
- Object
|
||||
- Scene
|
||||
- App
|
||||
- Saved
|
||||
|
||||
> [!NOTE]
|
||||
> If you’ve used an embed graph and do not want to lose your modifications, copy all the changes you made to the embed graph before exiting Play mode. Paste them back in when in edit mode. You can’t do this for any changed variables.
|
||||
|
||||
As a visual aid, connectors in Live mode display their execution flow with animated directional droplets going in the direction of execution. The speed and number of droplets does not represent the frequency or speed of execution.
|
||||
|
||||
## To adjust the graph during runtime
|
||||
|
||||
With a graph open do any or all of the following:
|
||||
|
||||
- In the Inspector, click in any field to change a component’s value. The values are not persistent and won’t save when you leave Play mode.
|
||||
- Right-click in an empty spot in the graph and add a node.
|
||||
- Connect nodes.
|
||||
- Delete any connectors.
|
||||
- Add an extension.
|
||||
- Add and link Debug nodes.
|
||||
- Change values directly in a node.
|
||||
|
||||
> [!TIP]
|
||||
> Select any GameObject that contains a script graph to see and work with the values of the selected GameObject during runtime.
|
||||
|
||||
> [!NOTE]
|
||||
> When you modify anything after a Start event during runtime you won’t get the update on the GameObject during that session. You need to restart the session for Unity to execute the new logic after the start event.
|
||||
|
||||
The changes you make to a graph are instantly shared across all instances of that saved graph asset.
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
# Live edit
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Visual Scripting supports live editing. In live editing you can create and edit graphs while in play mode and see the Visual Scripting updates in real time. This provides a fast way to iterate and test ideas without the need to recompile project changes.
|
||||
|
||||
## Working in live edit
|
||||
|
||||
Live editing is not limited to tweaking values — you can add and remove nodes, connections (edges), etc while live. Anything that can be done in a normal edit, can be done in a live edit.
|
||||
|
||||
In accordance with the Unity convention:
|
||||
|
||||
* Changes made to embeds are reverted when you exit play mode - the changes live inside components.
|
||||
* Changes made to graphs are saved when you exit play mode - the changes live inside assets
|
||||
|
||||
> [!TIP]
|
||||
> To preserve the changes made to a component graph, copy the modified nodes before exiting play mode. You'll then be able to paste back while in edit mode.
|
||||
|
||||
When in live mode, Visual Scripting is displayed the flow as droplets on connections.
|
||||
|
||||

|
||||
|
||||
To disable these animations on either the value connections, the control connections, or both, uncheck the **Animate Control Connections** or the **Animate Value Connections** from the editor preferences window (**Unity** > **Preferences** > **Visual Scripting** > **Script Graphs**).
|
||||
|
||||
## Saving changes through persistence
|
||||
|
||||
Visual Scripting graphs automatically saves the changes made during play mode.
|
||||
|
||||
## Propagation across graphs
|
||||
|
||||
Changes made to graphs are instantly shared across all instances of that graph.
|
@ -0,0 +1,64 @@
|
||||
# Add a State Unit to a Script Graph
|
||||
|
||||
Add a State Unit to a Script Graph to trigger a change of state. A state is any set of behaviors that you want a GameObject to perform. For more information on state in Visual Scripting, see [Graphs](vs-graph-types.md).
|
||||
|
||||
You can add a new State Graph to a State Unit node, or use an existing State Graph from the project. For more information on the State Unit node, see [State Unit node](vs-nesting-state-unit-node.md).
|
||||
|
||||
## Add a new State Graph as a State Unit node
|
||||
|
||||
To add a new blank State Graph as a State Unit node to a Script Graph:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]</p></li>
|
||||
<li><p>Go to <strong>Nesting</strong>.</p></li>
|
||||
<li><p>Select <strong>State Unit</strong> to add a State Unit node to the graph.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the Graph Inspector, choose the source for the State Unit:</p>
|
||||
<ul>
|
||||
<li><p><strong>Embed</strong>: The State Graph only exists on the State Unit node. You can only change the State Graph from the node in its parent graph.</p></li>
|
||||
<li><p><strong>Graph</strong>: The State Graph exists in a separate file. You can change the State Graph outside of its parent graph and reuse the graph in other areas of an application.</p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>If you chose <strong>Graph</strong>:</p>
|
||||
<ol type="a">
|
||||
<li><p>In the Graph Inspector, select <strong>New</strong>.</p></li>
|
||||
<li><p>Enter a name for the graph file.</p></li>
|
||||
<li><p>Choose where you want to save the graph file in the project.</p></li>
|
||||
<li><p>Select <strong>Save</strong>.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||

|
||||
|
||||
## Add an existing State Graph as a State Unit node
|
||||
|
||||
To add an existing State Graph file as a State Unit node in a Script Graph:
|
||||
|
||||
1. [!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]
|
||||
|
||||
2. Go to **Nesting**.
|
||||
|
||||
1. Select **State Unit** to add a State Unit node to the graph.
|
||||
|
||||
3. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, set the **Source** to **Graph**.
|
||||
|
||||
4. Do one of the following:
|
||||
- In the **Graph** field, select the object picker (circle icon) and choose a compatible State Graph from the project.
|
||||
- Click and drag a State Graph file from the Project window and release on the **Graph** field.
|
||||
|
||||
> [!TIP]
|
||||
> For a faster way to add a State Graph as a State Unit node:
|
||||
> - Click and drag a State Graph asset from the Project window into the Graph Editor to automatically create a State Unit node.
|
||||
> - Right-click to open the fuzzy finder. Go to **Graphs** and select a graph file.
|
||||
|
||||

|
||||
|
||||
|
||||
## Next steps
|
||||
|
||||
Select **Edit Graph** in the Graph Inspector to edit the graph. For more information on how to create a State Graph, see [Develop logic transitions with State Graphs](vs-state-graphs-intro.md).
|
||||
|
||||
|
@ -0,0 +1,67 @@
|
||||
# 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 a parent Script Graph. For more information on the Subgraph node, see [Subgraph node](vs-nesting-subgraph-node.md).
|
||||
|
||||
You can add a Subgraph to a Script Graph in two ways: create a 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:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]</p></li>
|
||||
<li><p>Go to <strong>Nesting</strong>.</p></li>
|
||||
<li><p>Select <strong>Subgraph</strong> to add a Subgraph node to the graph.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the Graph Inspector, choose the source for the Subgraph:</p>
|
||||
<ul>
|
||||
<li><p><strong>Embed</strong>: The Subgraph only exists on the Subgraph node. You can only change the Subgraph from the node in its parent graph.</p></li>
|
||||
<li><p><strong>Graph</strong>: The Subgraph exists in a separate file. You can change the Subgraph outside of its parent graph and reuse the graph in other areas of an application.</p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>If you chose <strong>Graph</strong>:</p>
|
||||
<ol type="a">
|
||||
<li><p>In the Graph Inspector, select <strong>New</strong>.</p></li>
|
||||
<li><p>Enter a name for the graph file.</p></li>
|
||||
<li><p>Choose where you want to save the graph file in the project.</p></li>
|
||||
<li><p>Select <strong>Save</strong>.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||

|
||||
|
||||
## 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. [!include[with-graph-open-ff](./snippets/vs-with-graph-open-ff.md)]
|
||||
|
||||
1. Go to **Nesting**.
|
||||
|
||||
1. Select **Subgraph** to add the Subgraph node to the graph.
|
||||
|
||||
2. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
1. In the Graph Inspector, set the **Source** to **Graph**.
|
||||
|
||||
3. Do one of the following:
|
||||
- In the **Graph** field, select the object picker (circle icon) and choose a compatible Script Graph from the project.
|
||||
- Click and drag a Script Graph file from the Project window and release on the **Graph** field.
|
||||
|
||||

|
||||
|
||||
> [!TIP]
|
||||
> For a faster way to add a Script Graph as a Subgraph:
|
||||
> - Click and drag a Script Graph asset from the Project window into the Graph Editor to automatically create a Subgraph node.
|
||||
> - Right-click to open the fuzzy finder. Go to **Graphs** and select a graph file.
|
||||
|
||||
## Next steps
|
||||
|
||||
To open the new Subgraph and edit the graph, select **Edit Graph**.
|
||||
|
||||
After you've added a Subgraph to a Script Graph, define its ports. For more information, see [Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md).
|
||||
|
@ -0,0 +1,91 @@
|
||||
# Add a Trigger or Data port to a Script Graph
|
||||
|
||||
A Script Graph used as a Subgraph can receive data and logic from its parent graph. Add and define ports on a graph to choose what data graphs can send and receive.
|
||||
|
||||
For more information about Subgraphs, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md).
|
||||
|
||||

|
||||
|
||||
## Add ports from a graph
|
||||
|
||||
To add a Trigger Input, Trigger Output, Data Input, or Data Output port to a Script Graph:
|
||||
|
||||
<ol>
|
||||
<li><p><a href="vs-open-graph-edit.md">Open the Script Graph</a> you want to edit in the Graph window.</p></li>
|
||||
<li><p>With no nodes or groups selected in the graph, open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>Select <strong>Add</strong> (+) under the port type you want to add:</p>
|
||||
<ul>
|
||||
<li><p><strong>Trigger Inputs</strong></p></li>
|
||||
<li><p><strong>Trigger Outputs</strong></p></li>
|
||||
<li><p><strong>Data Inputs</strong></p></li>
|
||||
<li><p><strong>Data Outputs</strong></p></li>
|
||||
</ul></li>
|
||||
<li><p>In the <strong>Key</strong> field, enter a unique key name for the port. The Key value can't match the Key of any existing ports on the current Script Graph.</p></li>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>If two <strong>Key</strong> values are the same on the same graph, Visual Scripting ignores the second port definition and displays a warning in the Graph Inspector. If you change the <strong>Key</strong> value for a port after you've made a connection to that port in a graph, the connections break and you must reconnect them.</p></div>
|
||||
<li><p>In the <strong>Label</strong> field, enter a label to display for the port. The label displays on the Subgraph node and its Input or Output node.</p></li>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>If you don't set a <strong>Label</strong>, Visual Scripting uses the value from the <strong>Key</strong> field.</p></div>
|
||||
<li><p>In the <strong>Summary</strong> field, enter a brief summary of the port to display in the Graph Inspector when you select the Subgraph node, Input node, or Output node.</p></li>
|
||||
<li><p>Toggle <strong>Hide Label</strong> to do the following:</p>
|
||||
<ul>
|
||||
<li><p>Enable <strong>Hide Label</strong> to hide the port label on any Subgraph node, Input node, or Output node.</p></li>
|
||||
<li><p>Disable <strong>Hide Label</strong> to display the data from the <strong>Label</strong> field.</p></li>
|
||||
</ul></li>
|
||||
<li><p>(Data Inputs and Data Outputs Only) Set a data type for the port:</p>
|
||||
<ol type="a">
|
||||
<li><p>Select the <strong>Type</strong> list to open the Type menu.</p></li>
|
||||
<li><p>Select a data type from the list to set the data type the port accepts.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><p>(Data Inputs Only) Enable <strong>Has Default Value</strong> to display the <strong>Default Value</strong> field. Disable <strong>Has Default Value</strong> to hide the <strong>Default Value</strong> field.</p>
|
||||
<ol type="a">
|
||||
<li><p>In the <strong>Default Value</strong> field, enter the default value the port uses if it doesn't receive a data input while the Script Graph runs.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
## Add ports with Input and Output nodes
|
||||
|
||||
You can also use an [Input node](vs-nesting-input-node.md) or an [Output node](vs-nesting-output-node.md) to define ports on a Script Graph:
|
||||
|
||||
<ol>
|
||||
<li><p><a href="vs-open-graph-edit.md">Open the Script Graph</a> you want to edit in the Graph window.</p></li>
|
||||
<li><p>[!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)]</p></li>
|
||||
<li><p>Go to <strong>Nesting</strong>.</p></li>
|
||||
<li><p>Do one of the following:</p>
|
||||
<ul>
|
||||
<li><p>To add a Trigger Input or Data Input port to the graph, select <strong>Input</strong>.</p></li>
|
||||
<li><p>To add a Trigger Output or Data Output port to the graph, select <strong>Output</strong>.</p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>Select the new Input or Output node in the graph.</p></li>
|
||||
<li><p>Open the <a href="vs-interface-overview.md#the-graph-inspector">Graph Inspector</a>.</p></li>
|
||||
<li><p>In the <strong>Key</strong> field, enter a unique key name for the port. The Key value can't match the Key of any existing ports on the current Script Graph.</p></li>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>If two <strong>Key</strong> values are the same on the same graph, Visual Scripting ignores the second port definition and displays a warning in the Graph Inspector. If you change the <strong>Key</strong> value for a port after you've made a connection to that port in a graph, the connections break and you must reconnect them.</p></div>
|
||||
<li><p>In the <strong>Label</strong> field, enter a label to display for the port. The label displays on the Subgraph node and its Input or Output node.</p></li>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>If you don't set a <strong>Label</strong>, Visual Scripting uses the value from the <strong>Key</strong> field.</p></div>
|
||||
<li><p>In the <strong>Summary</strong> field, enter a brief summary of the port to display in the Graph Inspector when you select the Subgraph node, Input node, or Output node.</p></li>
|
||||
<li><p>Toggle <strong>Hide Label</strong> to do the following:</p>
|
||||
<ul>
|
||||
<li><p>Enable <strong>Hide Label</strong> to hide the port label on any Subgraph node, Input node, or Output node.</p></li>
|
||||
<li><p>Disable <strong>Hide Label</strong> to display the data from the <strong>Label</strong> field.</p></li>
|
||||
</ul></li>
|
||||
<li><p>(Data Inputs and Data Outputs Only) Set a data type for the port:</p>
|
||||
<ol type="a">
|
||||
<li><p>Select the <strong>Type</strong> list to open the Type menu.</p></li>
|
||||
<li><p>Select a data type from the list to set the data type the port accepts.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><p>(Data Inputs Only) Enable <strong>Has Default Value</strong> to display the <strong>Default Value</strong> field. Disable <strong>Has Default Value</strong> to hide the <strong>Default Value</strong> field.</p>
|
||||
<ol type="a">
|
||||
<li><p>In the <strong>Default Value</strong> field, enter the default value the port uses if it doesn't receive a data input while the Script Graph runs.</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
## Next steps
|
||||
|
||||
Add the Script Graph as a Subgraph in another Script Graph. For more information on how to add a Script Graph as a Subgraph, see [Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md).
|
||||
|
||||
For more information on the port types on a Script Graph, see [Subgraph node](vs-nesting-subgraph-node.md).
|
||||
|
||||
The defined Trigger and Data ports affect the ports on the Input and Output nodes in a Script Graph. For more information, see [Input node](vs-nesting-input-node.md) and [Output node](vs-nesting-output-node.md).
|
@ -0,0 +1,39 @@
|
||||
# Input node
|
||||
|
||||
Use an Input node to control the flow of logic and data from a Script Graph's Subgraph node. An Input node takes data from a parent graph and makes it available to a Subgraph.
|
||||
|
||||

|
||||
|
||||
For more information on Subgraphs, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md) and [Subgraph node](vs-nesting-subgraph-node.md). For more information on Script Graphs, see [Graphs](vs-graph-types.md).
|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The Input node is in the **Nesting** category in the fuzzy finder.
|
||||
|
||||
## Available outputs
|
||||
|
||||
By default, an Input node has no ports.
|
||||
|
||||
An Input node can only have output ports. Define the number and specific data type for the output ports with the [Graph Inspector](vs-interface-overview.md#the-graph-inspector). For more information on how to define ports on a Script Graph, see [Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md).
|
||||
|
||||
| **Port Type** | **Description** |
|
||||
| :------------- | :-------------------- |
|
||||
| **Trigger Input** | A control port. Make a connection to this port to tell Visual Scripting what node to run next in the graph. Visual Scripting triggers any node to this port after the matching Trigger Input port triggers on the Subgraph node in the parent Script Graph. |
|
||||
| **Data Input** | A data port. Make a connection to this port to send a value or other data to another node in the graph. The data source is the matching Data Input port on the Subgraph node in a parent Script Graph. |
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the **Character Move** Subgraph uses an Input node to receive data from a parent graph. The Input node has one Trigger Input port and three Data Input ports. It uses the values from the parent graph and the values from two Input Get Axis nodes to create a new Vector 3 value that it sends back to its parent graph.
|
||||
|
||||

|
||||
|
||||
The parent graph sends three values from the current GameObject's Transform component to the Input node. The Subgraph reduces the number of nodes in the parent graph.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
Use an Input node with the following nodes:
|
||||
|
||||
- [Subgraph node](vs-nesting-subgraph-node.md)
|
||||
- [Output node](vs-nesting-output-node.md)
|
@ -0,0 +1,12 @@
|
||||
# Nesting nodes
|
||||
|
||||
Use the following nodes to work with nesting Subgraphs and State Units in a Script Graph.
|
||||
|
||||
For more information on Subgraphs and State Units, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md).
|
||||
|
||||
|**Node** | **Description** |
|
||||
| :---- | :-------------- |
|
||||
| [**Input node**](vs-nesting-input-node.md) | Use an Input node to control the flow of logic and data from a Script Graph's Subgraph node. An Input node takes data from a parent graph and makes it available to a Subgraph. |
|
||||
| [**Output node**](vs-nesting-output-node.md) | Use an Output node to control the flow of logic and data from a Script Graph's Subgraph node. An Output node sends data from a Subgraph and makes it available to a parent graph. |
|
||||
| [**State Unit node**](vs-nesting-state-unit-node.md) | Use a State Unit node like a Subgraph. The node references and triggers a State Graph as a State Unit inside a Script Graph. |
|
||||
| [**Subgraph node**](vs-nesting-subgraph-node.md) | Use a Subgraph node to reference and trigger another Script Graph's logic from inside a parent Script Graph. |
|
@ -0,0 +1,39 @@
|
||||
# Output node
|
||||
|
||||
Use an Output node to control the flow of logic and data from a Script Graph's Subgraph node. An Output node sends data from a Subgraph and makes it available to a parent graph.
|
||||
|
||||

|
||||
|
||||
For more information on Subgraphs, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md) and [Subgraph node](vs-nesting-subgraph-node.md). For more information on Script Graphs, see [Graphs](vs-graph-types.md).
|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The Output node is in the **Nesting** category in the fuzzy finder.
|
||||
|
||||
## Available inputs
|
||||
|
||||
By default, an Output node has no ports.
|
||||
|
||||
The Output node can only have input ports. Define the number and specific data type for the input ports with the [Graph Inspector](vs-interface-overview.md#the-graph-inspector). For more information on how to define ports on a Script Graph, see [Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md).
|
||||
|
||||
| **Port Type** | **Description** |
|
||||
| :------------- | :-------------------- |
|
||||
| **Trigger Output** | A control port. Make a connection to this port to tell Visual Scripting which node triggers its exit from the Subgraph and the return to the logic in a parent graph. After the Output node runs, Visual Scripting starts any connections made to the matching Trigger Output port on the Subgraph node. |
|
||||
| **Data Output** | A data port. Make a connection to this port to send data from a Subgraph to its parent graph. Visual Scripting returns any value from a node connected to this port to any node connected to the matching Data Output port on the Subgraph node. |
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the **Character Move** Subgraph uses an Input node to receive data from a parent graph. The Subgraph uses three values from the parent graph and the values from two Input Get Axis nodes to create a new Vector 3 value. The graph sends the new Vector 3 value to the Output node and back to the parent Script Graph. The Subgraph reduces the number of nodes in the parent graph.
|
||||
|
||||

|
||||
|
||||
The parent graph receives the Vector 3 value from the Output node. The parent graph uses that value to set a new position on the current GameObject's Transform component.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
Use an Output node with the following nodes:
|
||||
|
||||
- [Subgraph node](vs-nesting-subgraph-node.md)
|
||||
- [Input node](vs-nesting-input-node.md)
|
@ -0,0 +1,51 @@
|
||||
# State Unit node
|
||||
|
||||
Use a State Unit node like a Subgraph. The node references and triggers a State Graph inside a Script Graph.
|
||||
|
||||

|
||||
|
||||
A State Unit node:
|
||||
|
||||
- Can't send or receive any data from ports.
|
||||
- Can only trigger its associated State Graph or other nodes inside its parent Script Graph.
|
||||
- Can't change its number or type of ports.
|
||||
|
||||
For more information on Subgraphs and State Units, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md). For more information on State Graphs and Script Graphs, see [Graphs](vs-graph-types.md).
|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The State Unit node is in the **Nesting** category in the fuzzy finder.
|
||||
|
||||
You can go to the **Graphs** category and select any State Graph to create a State Unit node. For more information on how to create a State Unit node, see [Add a State Unit to a Script Graph](vs-nesting-add-state-unit.md).
|
||||
|
||||
## Inputs
|
||||
|
||||
The State Unit [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :---------- | :------- | :-------------- |
|
||||
| **Start** | Input Trigger | The first execution Input Trigger for the node. The connection made to this port indicates when Visual Scripting runs the nested State Graph. Visual Scripting makes all states marked as Start States in the State Graph active. |
|
||||
| **Stop** | Input Trigger | The second execution Input Trigger for the node. The connection made to this port indicates when Visual Scripting stops the nested State Graph. Visual Scripting makes all states and transitions in the State Graph inactive. |
|
||||
|
||||
|
||||
## Outputs
|
||||
|
||||
The State Unit [!include[nodes-outputs](./snippets/nodes-outputs.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :--------- | :------- | :-------------- |
|
||||
| **Started** | Output Trigger| The first execution Output Trigger for the node. The connection made to this port indicates what Visual Scripting runs after the nested State Graph starts. |
|
||||
| **Stopped** | Output Trigger| The second execution Output Trigger for the node. The connection made to this port indicates what Visual Scripting runs after the nested State Graph stops. |
|
||||
|
||||
|
||||
## Example graph usage
|
||||
|
||||
> [!TIP]
|
||||
> A State Unit node can use a new blank State Graph or an existing State Graph from a project. For more information, see [Add a State Unit to a Script Graph](vs-nesting-add-state-unit.md).
|
||||
|
||||
In the following example, a State Unit node triggers when the Script Graph's GameObject enters a specific Collider marked as a trigger. After the State Unit node starts, the Script Graph uses a Debug Log node to log `Started new state!` to the console. When the GameObject leaves the Collider, the State Unit node stops, and the Script Graph uses another Debug Log node to log `Exited state` to the console.
|
||||
|
||||

|
||||
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
# Subgraph node
|
||||
|
||||
Use a Subgraph node to reference and trigger another Script Graph's logic from inside a parent Script Graph.
|
||||
|
||||

|
||||
|
||||
For more information on Subgraphs, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md). For more information on Script Graphs, see [Graphs](vs-graph-types.md).
|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The Subgraph node is in the **Nesting** category in the fuzzy finder.
|
||||
|
||||
You can go to the **Graphs** category and select any Script Graph to create a Subgraph node. For more information on how to create a Subgraph, see [Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md).
|
||||
|
||||
## Available ports
|
||||
|
||||
By default, a Subgraph node has no ports.
|
||||
|
||||
Use the [Graph Inspector](vs-interface-overview.md#the-graph-inspector) to specify the following on a Script Graph:
|
||||
|
||||
- Trigger Inputs.
|
||||
- Trigger Outputs.
|
||||
- Data Inputs.
|
||||
- Data Outputs.
|
||||
|
||||
These determine the type and number of ports available on its Subgraph node. For more information on how to define ports on a Script Graph, see [Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md).
|
||||
|
||||
| **Port type** | **Description** |
|
||||
| :------------- | :-------------------- |
|
||||
| **Trigger Input** | Adds a control input port to the Subgraph node for the Script Graph. Use a Trigger Input to choose which node or nodes from a parent graph triggers Visual Scripting to run the logic in the Subgraph. |
|
||||
| **Trigger Output** | Adds a control output port to the Subgraph node for the Script Graph. Use a Trigger Output to choose which node or nodes Visual Scripting triggers after the logic contained in the Subgraph finishes. |
|
||||
| **Data Input** | Adds a data input port to the Subgraph node for the Script Graph. Use a Data Input to receive data from a parent graph. |
|
||||
| **Data Output** | Adds a data output port to the Subgraph node for the Script Graph. Use a Data Output to send data back to a parent graph. |
|
||||
|
||||
## Example graph usage
|
||||
|
||||
> [!TIP]
|
||||
> A Subgraph node can use a new blank Script Graph or an existing Script Graph from a project. For more information, see [Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md).
|
||||
|
||||
In the following example, the Subgraph node **Character Move** references a graph that makes a GameObject move based on a user's input. It has the following:
|
||||
|
||||
- One Trigger Input port.
|
||||
- One Trigger Output port.
|
||||
- Three Data Input ports.
|
||||
- One Data Output port.
|
||||
|
||||
After every Update Event in the application, the **Character Move** Subgraph node triggers and takes the X, Y, and Z coordinates of the current GameObject's Transform component. The Subgraph node then outputs a new Vector 3 value, which the parent graph assigns to the current GameObject with a Transform Set Position node.
|
||||
|
||||

|
||||
|
||||
The Subgraph node reduces the number of nodes in the parent graph.
|
||||
|
||||
> [!TIP]
|
||||
> To see the Script Graph attached to the Subgraph node in this example, see either [Input node](vs-nesting-input-node.md) or [Output node](vs-nesting-output-node.md).
|
||||
|
||||
## Related nodes
|
||||
|
||||
Use a Subgraph node with the following nodes:
|
||||
|
||||
- [Input node](vs-nesting-input-node.md)
|
||||
- [Output node](vs-nesting-output-node.md)
|
@ -0,0 +1,57 @@
|
||||
# Subgraphs and State Units
|
||||
|
||||
In a Script Graph, you can add a node that links directly to another Script Graph or State Graph.
|
||||
|
||||
- A nested Script Graph is a Subgraph.
|
||||
- A nested State Graph is a State Unit.
|
||||
|
||||
A nested Script Graph or State Graph helps you to organize and reuse logic across an application. A Subgraph or State Unit can exist as the node that adds it to a graph, or it can link to an external graph file.
|
||||
|
||||

|
||||
|
||||
## Subgraphs
|
||||
|
||||
A Subgraph nests a Script Graph inside another Script Graph. Use a Subgraph node to reuse a set of logic across Script Graphs in an application.
|
||||
|
||||
A Subgraph node can take inputs or send outputs back to its parent graph. Add ports to configure what data a Subgraph and its parent graph send to each other.
|
||||
|
||||
### Subgraph inputs and outputs
|
||||
|
||||
With the Graph Inspector, you can choose and define the ports that appear when you use a Script Graph as a Subgraph. The port definitions for a Script Graph appear in the [Graph Inspector](vs-interface-overview.md#the-graph-inspector) when you have no other items selected in a graph.
|
||||
|
||||

|
||||
|
||||
Defined ports appear on any Subgraph node that uses that Script Graph. In the following image, the Subgraph **Rotate the Cube** has:
|
||||
|
||||
- A Trigger Input port.
|
||||
- An Data Input port.
|
||||
- An Trigger Output port.
|
||||
- An Data Output port.
|
||||
|
||||

|
||||
|
||||
A port definition also changes the **Input** and **Output** nodes for a Subgraph. These nodes control the execution and flow between a Subgraph and its parent graph. In the following image, the Input and Output nodes have the same ports as the **Rotate the Cube** Subgraph node from the previous example.
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> You can only use a single **Input** node and a single **Output** node in a Script Graph. If you add more **Input** or **Output** nodes, Visual Scripting only uses the first **Input** and **Output** nodes you added to the graph.
|
||||
|
||||
For more information on how to add ports to a Script Graph, see [Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md). For more information on the different types of ports, see [Subgraph node](vs-nesting-subgraph-node.md). For more information on how to use a Subgraph, see [Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md).
|
||||
|
||||
## State Units
|
||||
|
||||
A State Unit starts a State Graph from a Script Graph. You can't change the ports that appear on a State Unit node or send data between the State Graph and its parent Script Graph.
|
||||
|
||||

|
||||
|
||||
The State Unit node starts different logic in a Script Graph, at different times in code execution:
|
||||
|
||||
- When the nested State Graph starts to run.
|
||||
- While the nested State Graph runs.
|
||||
- When the nested State Graph stops.
|
||||
- After the nested State Graph stops.
|
||||
|
||||
When you start a State Unit node's Start and Started ports in a parent graph, Visual Scripting marks all Start states inside the node's State Graph as active. When you start the Stop and Stopped ports, Visual Scripting marks all Start states as inactive.
|
||||
|
||||
For more information on State Graphs and Start states, see [State Graphs](vs-graph-types.md#state-graphs). For more information on the State Unit node, see [State Unit node](vs-nesting-state-unit-node.md) and [Add a State Unit to a Script Graph](vs-nesting-add-state-unit.md).
|
@ -0,0 +1,85 @@
|
||||
# On Input System Event Button node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Input System Event Button node [!include[nodes-note-package](./snippets/input-system/nodes-note-package.md)]
|
||||
|
||||
The On Input System Event Button node listens for a specific Input Action from a Player Input component. It doesn't send or read any other data.
|
||||
|
||||
Use this node when you want to read user input but don't require any other data from an Input Action.
|
||||
|
||||

|
||||
|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Input System Event Button node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Input System Event Button [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
[!include[nodes-input-system-ports](./snippets/input-system/nodes-input-system-ports.md)]
|
||||
|
||||
|
||||
## Controls
|
||||
|
||||
The On Input System Event Button [!include[nodes-controls](./snippets/nodes-controls.md)]
|
||||
|
||||
[!include[nodes-input-action-change](./snippets/input-system/nodes-input-action-change.md)]
|
||||
|
||||
You can also set this control from the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Input System Event Button [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Input System Event Button [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-system-output-trigger-port](./snippets/input-system/nodes-input-system-output-trigger-port.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, an On Input System Event Button node counts how many times the user has pressed a button from the **Fire** Input Action and logs the result to the console.
|
||||
|
||||
When a user presses a button associated with the **Fire** Input Action, Visual Scripting gets the current value of the `Count` Object variable with a Get Variable node. The Get Variable node sends `Count`'s current value to an Add Inputs node's **A** port. Then, the Float literal node sends a value of `1` to the Add Inputs node's **B** port.
|
||||
|
||||
The On Input System Event Button node triggers the Set Variable node and assigns the value from the Add Inputs node's **Sum** port as the **New Value** of **Count**. The Set Variable node logs the value of **Count** to the console with the Debug Log node:
|
||||
|
||||

|
||||
|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[vs-nodes-related](./snippets/nodes-related.md)] On Input System Event Button node:
|
||||
|
||||
- [On Input System Event Float node](vs-nodes-events-input-system-float.md)
|
||||
- [On Input System Event Vector 2 node](vs-nodes-events-input-system-vector2.md)
|
@ -0,0 +1,84 @@
|
||||
# On Input System Event Float node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Input System Event Float node [!include[nodes-note-package](./snippets/input-system/nodes-note-package.md)]
|
||||
|
||||
The On Input System Event Float node lists for a specific Input Action from a Player Input component. The node can output a single float value.
|
||||
|
||||
Use this node when you want to read user input and return a single value, such as an axis value or input from a trigger on a controller.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Input System Event Float node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Input System Event Float [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
[!include[nodes-input-system-ports](./snippets/input-system/nodes-input-system-ports.md)]
|
||||
|
||||
## Controls
|
||||
|
||||
The On Input System Event Float [!include[nodes-controls](./snippets/nodes-controls.md)]
|
||||
|
||||
[!include[nodes-input-action-change](./snippets/input-system/nodes-input-action-change.md)]
|
||||
|
||||
You can also set this control from the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Input System Event Float [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Input System Event Float [!include[nodes-outputs](./snippets/nodes-outputs.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-system-output-trigger-port](./snippets/input-system/nodes-input-system-output-trigger-port.md)]
|
||||
<tr>
|
||||
<td><strong>Float Value</strong></td>
|
||||
<td>Float</td>
|
||||
<td>A float output port. <br/>Visual Scripting uses your chosen Input Action and its configuration in your Input Actions asset to determine the float value returned by this port. See the <a href="#example-graph-usage">Example graph usage</a> section for an example. <br/>For more information about how to configure Input Action settings and use an Input Action asset, see <a href="(https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/ActionAssets.html)">Input Action Assets</a> in the Input System package documentation.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, an On Input System Event Float node uses the bindings assigned to the **Lift** Input Action. When a user presses any key from the **Lift** binding, Visual Scripting takes the float value it receives from the Input System and sends it as an input to the Vector 3 Create node's **Y** input port. At the same time, Visual Scripting triggers the Transform Set Position node and uses the output from the Vector 3 Create node to set a new position for the Script Machine's GameObject.
|
||||
|
||||

|
||||
|
||||
For this example, **Lift** uses a Right Trigger from a Gamepad input device as a binding. When a user presses the Right Trigger, the **Y** value of the GameObject's transform increases, which makes the GameObject move upwards in the scene.
|
||||
|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[vs-nodes-related](./snippets/nodes-related.md)] On Input System Event Float node:
|
||||
|
||||
- [On Input System Event Button node](vs-nodes-events-input-system-button.md)
|
||||
- [On Input System Event Vector 2 node](vs-nodes-events-input-system-vector2.md)
|
@ -0,0 +1,83 @@
|
||||
# On Input System Event Vector 2 node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Input System Event Vector 2 node [!include[nodes-note-package](./snippets/input-system/nodes-note-package.md)]
|
||||
|
||||
The On Input System Event Vector 2 node listens for a specific Input Action from a Player Input component. The node can output two values as a Vector 2.
|
||||
|
||||
Use this node when you want to read input and return two values, such as a joystick or mouse position.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Input System Event Vector 2 node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Input System Event Vector 2 [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
[!include[nodes-input-system-ports](./snippets/input-system/nodes-input-system-ports.md)]
|
||||
|
||||
## Controls
|
||||
|
||||
The On Input System Event Vector 2 [!include[nodes-controls](./snippets/nodes-controls.md)]
|
||||
|
||||
[!include[nodes-input-action-change](./snippets/input-system/nodes-input-action-change.md)]
|
||||
|
||||
You can also set this control from the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Input System Event Vector 2 [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Input System Event Vector 2 [!include[nodes-outputs](./snippets/nodes-outputs.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-system-output-trigger-port](./snippets/input-system/nodes-input-system-output-trigger-port.md)]
|
||||
<tr>
|
||||
<td><strong>Vector 2 Value</strong></td>
|
||||
<td>Vector 2</td>
|
||||
<td>A Vector 2 output port. <br/>Visual Scripting uses your chosen Input Action and its configuration in your Input Actions asset to determine the Vector 2 value returned by this port. See the <a href="#example-graph-usage">Example graph usage</a> section for an example. <br/>For more information about how to configure Input Action settings and use an Input Action asset, see <a href="(https://docs.unity3d.com/Packages/com.unity.inputsystem@latest/index.html?subfolder=/manual/ActionAssets.html)">Input Action Assets</a> in the Input System package documentation.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, an On Input System Event Vector 2 node uses the bindings assigned to the **Move** Input Action. When a user presses a button from the **Move** binding, Visual Scripting takes the Vector 2 value it receives from the Input System and sends it as an input to the Transform Set Position node's **Value** input port. The Vector 2 value changes the position of the GameObject associated with the **Target** transform.
|
||||
|
||||

|
||||
|
||||
For this example, **Move** uses the W, A, S, and D keys. The GameObject moves up in the scene when the user presses W, moves down when the user presses S, and moves left or right when the user presses A or D.
|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[vs-nodes-related](./snippets/nodes-related.md)] On Input System Event Vector 2 node:
|
||||
|
||||
- [On Input System Event Button node](vs-nodes-events-input-system-button.md)
|
||||
- [On Input System Event Float node](vs-nodes-events-input-system-float.md)
|
@ -0,0 +1,110 @@
|
||||
# On Button Input node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Button Input [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Button Input node listens for a specified action on a virtual button from your Input Manager configuration. [!include[nodes-desc-end](./snippets/input-manager/nodes-desc-end.md)]
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Button Input node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Button Input [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Name</strong></td>
|
||||
<td>String</td>
|
||||
<td colspan="2">The name of the button the node listens to for an Input event, as it appears in the Input Manager.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4"><strong>Action</strong></td>
|
||||
<td rowspan="4">Press State</td>
|
||||
<td colspan="2">The specific press state of the button that the node listens for.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Hold</strong></td>
|
||||
<td>The user holds down the button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Down</strong></td>
|
||||
<td>The user presses the button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Up</strong></td>
|
||||
<td>The user releases the button.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Button Input [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Button Input [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Button Input node listens for the user to press the button or key assigned to the **Jump** axes in the Input Manager. When the user presses the button, the On Button Input node triggers the Rigidbody Add Force node, which adds an **Impulse** Force to the Rigidbody's **Y** axis:
|
||||
|
||||

|
||||
|
||||
The Add Force node makes the **Target** Rigidbody lift into the air.
|
||||
|
||||

|
||||
|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] to the On Button Input node:
|
||||
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,107 @@
|
||||
# On Keyboard Input node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Keyboard Input [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Keyboard Input node listens for a specified action on a keyboard key. [!include[nodes-desc-end](./snippets/input-manager/nodes-desc-end.md)]
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Keyboard Input node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Keyboard Input [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Key</strong></td>
|
||||
<td>Key Code</td>
|
||||
<td colspan="2">The name of the keyboard key the node listens to for an Input event. For a list of all available keys, see the <a href="https://docs.unity3d.com/2019.1/Documentation/ScriptReference/KeyCode.html">KeyCode</a> page's Properties section in the Unity User manual.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4"><strong>Action</strong></td>
|
||||
<td rowspan="4">Press State</td>
|
||||
<td colspan="2">The specific press state of the key that the node listens for.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Hold</strong></td>
|
||||
<td>The user holds down the key.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Down</strong></td>
|
||||
<td>The user presses the key.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Up</strong></td>
|
||||
<td>The user releases the key.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Keyboard Input [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Keyboard Input [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Keyboard Input node listens for when the user presses the **Space** key. When the user presses **Space**, the On Keyboard Input triggers the Transform Translate node and lifts the GameObject along its `Y` coordinate by `5` units. This makes the GameObject jump.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] the On Keyboard Input node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,79 @@
|
||||
# On Mouse Down node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Down [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Down node listens for a mouse click action on a specific GameObject in your application. [!include[nodes-desc-end](./snippets/input-manager/nodes-desc-end.md)]
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Down node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Down [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject that the user needs to click with their mouse to trigger the On Mouse Down node. |
|
||||
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Down [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Down [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Down node listens for a click action on the GameObject where the graph runs. When a user clicks the GameObject, the On Mouse Down node triggers the GameObject Instantiate node. The Instantiate node creates a new GameObject, based on the **Ball** Prefab. It creates the Ball at a specific **Position**. It uses the Transform Get Local Rotation to match the new GameObject's **Rotation** to the GameObject where the Script Graph runs. Then, the graph adds a Rigidbody component to the new GameObject, and uses a Rigidbody Add Force node to add an **Impulse** force.
|
||||
|
||||

|
||||
|
||||
When the user clicks the mouse button, the Script Graph creates a new **Ball** GameObject and sends it towards the camera.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Down node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,80 @@
|
||||
# On Mouse Drag node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Drag [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Drag node listens for a mouse click and hold on a specific GameObject in your application. It triggers the next node connected to it as long as the mouse button is held down on that GameObject. It doesn't send or receive any other data.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Drag node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Drag [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject the user needs to click and hold with their mouse to trigger the On Mouse Drag node. |
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Drag [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Drag [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Drag node triggers a Camera Screen To World Point node. When the user clicks and holds their mouse button over the **Target** GameObject from the On Mouse Drag node, the Script Graph gets the user's current mouse position with an Input Get Mouse Position node. The graph uses the X and Y values from the Get Mouse Position node's Vector 3 result to create a new Vector 3 value, with a fixed Z value. The Screen To World Point node uses the new Vector 3 and the camera saved in the **Main Camera** Scene variable to set the position of the **Target** GameObject's transform.
|
||||
|
||||

|
||||
|
||||
The Script Graph allows the user to drag the **Target** GameObject around the scene when hold down their mouse button.
|
||||
|
||||

|
||||
|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Drag node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
||||
|
@ -0,0 +1,79 @@
|
||||
# On Mouse Enter node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Enter [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Enter node listens for the user's mouse pointer location to enter the Collider of a specified GameObject. When the mouse enters the Collider or GUI element, the node triggers the next node connected to it. It doesn't send or receive any other data.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Enter node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Enter [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject with the Collider that triggers the On Mouse Enter node. |
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Enter [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Enter [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Enter node triggers the Instantiate GameObject node when the user's mouse enters the Collider on the Script Machine's GameObject. The Instantiate node creates an instance of the **Light** Prefab, at the Prefab's **Position** and with the Prefab's **Rotation**. The graph saves the new instance of the GameObject to a Scene variable, **Spotlight**, so it can interact with the GameObject again later.
|
||||
|
||||

|
||||
|
||||
The result is a spotlight that appears over the On Mouse Enter node's **Target** GameObject, when the user's mouse enters the Collider.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Enter node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
||||
|
@ -0,0 +1,78 @@
|
||||
# On Mouse Exit node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Exit [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Exit node listens for the user's mouse pointer location to exit the Collider of a specified GameObject. When the mouse exits the Collider or GUI element, the node triggers the next node connected to it. It doesn't send or receive any other data.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Exit node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Exit [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject with the Collider that triggers the On Mouse Exit node. |
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Exit [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Exit [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, continued from the example from the [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md), the On Mouse Exit node triggers a Destroy GameObject node when the user's mouse exits the Collider on the Script Machine's GameObject. The Destroy GameObject node destroys the GameObject assigned to the Spotlight Scene variable. The GameObject was created and assigned to the variable elsewhere in the graph.
|
||||
|
||||

|
||||
|
||||
When the user's mouse leaves the Collider, the **Target** GameObject no longer has a spotlight.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Exit node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,113 @@
|
||||
# On Mouse Input node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Input [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Input node listens for a specific action on a user's mouse. The action doesn't need to happen on a specific GameObject's Collider. [!include[nodes-desc-end](./snippets/input-manager/nodes-desc-end.md)]
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Input node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Input [!include[nodes-inputs](./snippets/nodes-inputs.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Button</strong></td>
|
||||
<td>Mouse Button</td>
|
||||
<td colspan="2">The name of the mouse button that triggers the On Mouse Input node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4"><strong>Action</strong></td>
|
||||
<td rowspan="4">Press State</td>
|
||||
<td colspan="2">The specific state of the mouse button that the node listens for.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Hold</strong></td>
|
||||
<td>The user holds down the mouse button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Down</strong></td>
|
||||
<td>The user presses the mouse button.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Up</strong></td>
|
||||
<td>The user releases the mouse button.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Input [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Input [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Input node listens for the user to hold the right mouse button and triggers an Instantiate Camera node. The Instantiate node clones the camera saved as the **Camera1** Scene variable and assigns it to the **NewCamera** Scene variable. It sets a new position for the cloned camera with a Transform Set Position node, before it switches which camera renders in the Game view with the Camera Render node.
|
||||
|
||||

|
||||
|
||||
When the application runs, the default view in the Game view displays all three spheres in the scene.
|
||||
|
||||

|
||||
|
||||
When the user holds the right mouse button and triggers the On Mouse Input node, the Game view changes to focus on the middle sphere.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Input node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,80 @@
|
||||
# On Mouse Over node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Over [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Over node listens for a user's mouse to land over a specified GameObject's Collider. While the user's mouse is over the Collider, it triggers the next node connected to it once every frame. It doesn't send or receive any other data.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Over node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Over [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject with the Collider that triggers the On Mouse Over node. |
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Over [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Over [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Over node triggers a Timer node when the user moves their mouse over the **Target** GameObject. The Timer runs for 2 seconds and triggers a Color Lerp node. For every **Tick** of the Timer node, the Color Lerp node uses the **Elapsed** value to calculate a new Color between Color **A** and Color **B** to make a smooth transition between colors. The Material Set Color node uses the **Result** from the Color Lerp node to set a new Color on the **Object** material.
|
||||
|
||||

|
||||
|
||||
While the user's mouse is over the **Target** GameObject, the objects that use the **Object** material in the scene transition from red to blue over two seconds. The transition repeats until the user's mouse leaves the **Target**'s Collider.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Over node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,85 @@
|
||||
# On Mouse Up As Button node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Up As Button [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Up As Button node listens for a user to release their mouse button after they click a Collider in your application. [!include[nodes-desc-end](./snippets/input-manager/nodes-desc-end.md)]
|
||||
|
||||
To trigger the On Mouse Up As Button node, the user must release their mouse button over the same Collider they clicked. If you want the user to trigger the node after they release their mouse button at any location in your application, use the [On Mouse Up node](vs-nodes-events-on-mouse-up.md) instead.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Up As Button node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Up As Button [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject the user must click and release with their mouse button to trigger the node. |
|
||||
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Up As Button [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Up As Button [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Up As Button node runs as a coroutine to load a new scene after the user clicks and releases their mouse button over the **Target** GameObject. The Script Graph loads the scene, makes the graph wait until the scene loads, then sets the loaded scene as the active scene in the application.
|
||||
|
||||

|
||||
|
||||
When the application starts, the active scene contains a plane with three spheres.
|
||||
|
||||

|
||||
|
||||
After the Script Graph runs, the scene changes to a plane with a single cube.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Up As Button node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up node](vs-nodes-events-on-mouse-up.md)
|
@ -0,0 +1,81 @@
|
||||
# On Mouse Up node
|
||||
|
||||
> [!NOTE]
|
||||
> The On Mouse Up [!include[nodes-note-manual](./snippets/input-manager/nodes-note-manual.md)]
|
||||
|
||||
The On Mouse Up node listens for a user to release their mouse button after they click a Collider in your application. [!include[nodes-desc-end](./snippets/input-manager/nodes-desc-end.md)]
|
||||
|
||||
The user can release their mouse button anywhere in your application to trigger the On Mouse Up node. If you want the node to trigger after the user releases the mouse button over the same Collider specified in the node's **Target**, use the [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md) instead.
|
||||
|
||||

|
||||
|
||||
## Fuzzy finder category
|
||||
|
||||
The On Mouse Up node is in the **Events** > **Input** category in the fuzzy finder.
|
||||
|
||||
## Inputs
|
||||
|
||||
The On Mouse Up [!include[nodes-single-input](./snippets/nodes-single-input.md)]
|
||||
|
||||
| **Name** | **Type** | **Description** |
|
||||
| :------ | :---------- | :------------- |
|
||||
| **Target** | GameObject | The GameObject the user needs to click with their mouse button to have the On Mouse Up node listen for a mouse button release action. The user can release their mouse button anywhere to trigger the On Mouse Up node, but they must click the GameObject specified as the **Target**. |
|
||||
|
||||
|
||||
## Additional node settings
|
||||
|
||||
The On Mouse Up [!include[nodes-additional-settings](./snippets/nodes-additional-settings.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Outputs
|
||||
|
||||
The On Mouse Up [!include[nodes-single-output](./snippets/nodes-single-output.md)]
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Type</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Example graph usage
|
||||
|
||||
In the following example, the On Mouse Up node adds a force to a GameObject based on the user's mouse position when they release their mouse button. The On Mouse Up node triggers a Camera Screen To World Point node to get the user's mouse position, before it sends the **X** value of the mouse to a Rigidbody Add Force node to move the GameObject.
|
||||
|
||||

|
||||
|
||||
When the user clicks on the sphere in the middle of the scene and releases their mouse button, the sphere moves towards their mouse location.
|
||||
|
||||

|
||||
|
||||
## Related nodes
|
||||
|
||||
[!include[nodes-related](./snippets/nodes-related.md)] On Mouse Up node:
|
||||
|
||||
- [On Button Input node](vs-nodes-events-on-button-input.md)
|
||||
- [On Keyboard Input node](vs-nodes-events-on-keyboard-input.md)
|
||||
- [On Mouse Down node](vs-nodes-events-on-mouse-down.md)
|
||||
- [On Mouse Drag node](vs-nodes-events-on-mouse-drag.md)
|
||||
- [On Mouse Enter node](vs-nodes-events-on-mouse-enter.md)
|
||||
- [On Mouse Exit node](vs-nodes-events-on-mouse-exit.md)
|
||||
- [On Mouse Input node](vs-nodes-events-on-mouse-input.md)
|
||||
- [On Mouse Over node](vs-nodes-events-on-mouse-over.md)
|
||||
- [On Mouse Up As Button node](vs-nodes-events-on-mouse-up-button.md)
|
@ -0,0 +1,34 @@
|
||||
# Node reference
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Nodes are the most basic element of computation in visual scripting. Nodes display the required information as text, but editing is done via the Inspector. To edit them, select any node and edit its properties in the Inspector.
|
||||
|
||||
## This node
|
||||
|
||||
The [This](vs-self.md) node returns the game object that owns the machine in which the graph runs.
|
||||
|
||||
## Control nodes
|
||||
|
||||
[Control](vs-control.md) nodes branch, loop and merge the flow.
|
||||
|
||||
## Time nodes
|
||||
|
||||
[Time](vs-time.md) nodes include timer, cooldown and wait nodes.
|
||||
|
||||
## Events
|
||||
|
||||
Scripting nodes listen for [events](vs-events-reference.md). They are the starting point for all scripts and appear as special green nodes in graphs.
|
||||
|
||||
## Variables
|
||||
|
||||
These nodes get, set, and check [variables](vs-variables-reference.md).
|
||||
|
||||
## Nulls
|
||||
|
||||
Nodes that deal with the [nulls](vs-nulls.md), a.k.a. "nothing" value.
|
||||
|
||||
## Formulas
|
||||
|
||||
[Formula](vs-formula.md) evaluates logical and mathematical expressions directly via a textual Formula and match with multiple arguments.
|
@ -0,0 +1,95 @@
|
||||
# Nodes
|
||||
|
||||
Nodes are the most basic part of scripts in Visual Scripting. A node can listen for events, get the value of a variable, modify a component on a GameObject, and more.
|
||||
|
||||
Nodes appear as blocks in [the Graph Editor](vs-interface-overview.md#the-graph-editor).
|
||||
|
||||

|
||||
|
||||
You can arrange and connect these blocks with edges to create logic for an application. Add nodes with [the fuzzy finder](vs-interface-overview.md#the-fuzzy-finder). Click and drag a node to move it in the Graph Editor.
|
||||
|
||||
## Node anatomy
|
||||
|
||||
Visual Scripting highlights nodes in your current selection. All nodes have a header, which displays the node's name. Some node headers might contain additional information or controls.
|
||||
|
||||
Select a node in your graph, the Visual Scripting [Graph Inspector](vs-interface-overview.md#the-graph-inspector) displays the following information:
|
||||
|
||||
- The node's name and type icon.
|
||||
- A brief description of what the node does, if available.
|
||||
- The current warning messages or errors for the node.
|
||||
- The additional settings for the node, if available.
|
||||
- The required type for each input port and a brief description, if available.
|
||||
- The type for each output port and a brief description, if available.
|
||||
|
||||
### Connections and ports
|
||||
|
||||
Connect a port from one node to a compatible port on another node to create an edge. Edges form the logic flow in a Visual Scripting graph. Click any port to create a new edge.
|
||||
|
||||
Edges are color-coded: edges that control the logic flow in your graph are white. Data edges are colored based on their type. For more information about types, see [Object types](vs-types.md).
|
||||
|
||||
When you create a new edge, Visual Scripting highlights ports on any other nodes in a graph where you can make a valid connection. If you enable **Dim Incompatible Nodes**, Visual Scripting also dims any nodes or ports without a valid connection.
|
||||
|
||||
Ports on the left side of a node are Input Ports. Ports on the right side of a node are Output Ports.
|
||||
|
||||
An input port or output port can be a Control Port or a Data Port:
|
||||
|
||||
- Control Ports control the logical flow in a graph. They tell Visual Scripting what order to execute the nodes in a graph, from left to right. The icon for a control port is always an arrow. These arrows display the direction of the flow of logic in a graph.
|
||||
- Data Ports send and receive data, such as number values or GameObjects, between nodes. They have colors that correspond to the specific type they expect to receive as inputs, or send as outputs. Their icons change based on their type.
|
||||
|
||||
You can make multiple connections to or from the same port, with some restrictions:
|
||||
|
||||
- You can connect a single Data Output port to multiple Data Input ports.
|
||||
- You can't connect multiple Data Output ports to a single Data Input port. Visual Scripting can't choose which value to use.
|
||||
- You can connect multiple Control Output ports a single Control Input port.
|
||||
- You can't connect a single Control Output port to multiple Control Input ports. Visual Scripting can't choose which node to run first.
|
||||
|
||||

|
||||
|
||||
For more information on how to connect nodes, see [Connect nodes in a Script Graph](vs-creating-connections.md).
|
||||
|
||||
More complex nodes can have more complex or specialized ports, outside of the ports described here.
|
||||
### Node controls and inline values
|
||||
|
||||
A node might have additional controls that display on its header or in the [Graph Inspector](vs-interface-overview.md#the-graph-inspector). Controls can change the available ports or behavior of a node. Some ports might also use inline values.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Element</strong></th>
|
||||
<th><strong>Example</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Control</strong></td>
|
||||
<td> <img src="images\vs-node-container-type.png"></td>
|
||||
<td>A control appears as a dropdown option on the header of a node. For example, a Container Type control might tell a node to expect to receive a GameObject instead of a Script Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Inline Value</strong></td>
|
||||
<td> <img src="images\vs-node-inline-value.png"></td>
|
||||
<td>An inline value appears as an object picker field next to a port. You can use an inline value instead of a node connection to specify a value for a node. Not all Visual Scripting types support inline values.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Node overloads
|
||||
|
||||
Variations of a Visual Scripting node are called overloads. Overloads change the input and output data that a node can accept, and can change the number of input or output data ports on a node.
|
||||
|
||||
For example, the **Add** node has four overloads, as shown in the following image of the fuzzy finder after a search for `Add`.
|
||||
|
||||

|
||||
|
||||
You can distinguish each overload through its subcategory in the fuzzy finder. The **Add** node is a part of the **Math** category, but each overload is a part of a different subcategory: **Generic**, **Scalar**, **Vector 2**, **Vector 3**, or **Vector 4**.
|
||||
|
||||
The specific node overload changes what input and output data the **Add** node can accept. While a Generic **Add** node can input and output any object type in Visual Scripting, a Vector 3 **Add** node can only take 3D vectors as an input, and can only output a single 3D vector:
|
||||
|
||||

|
||||
|
||||
The default type and number of ports on the **Add** node stays consistent across its overloads. For the **Rotate** node, the type and number of ports varies.
|
||||
|
||||

|
||||
|
||||
Based on the **Rotate** node you select, you might be able to specify the angle of rotation as a vector, as separate float values, or as an angle relative to each axis. You can also choose whether the node rotates the GameObject relative to itself, or relative to the center of the scene's world space.
|
@ -0,0 +1,27 @@
|
||||
# Nulls node
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Null nodes deal with the null value, which is scripting lingo for "nothing".
|
||||
|
||||
## The null node
|
||||
|
||||
The null node always returns null as a value. Leaving a Unity object reference field empty ("None") automatically means null.
|
||||
|
||||
|
||||
## Null Check
|
||||
|
||||
The null check is a shortcut for a branch on an equality comparison with null. It can be useful to direct the flow in different directions depending on whether a value is null.
|
||||
|
||||
For example, it can be used to handle a situation differently whether a transform has a parent in the hierarchy or not.
|
||||
|
||||

|
||||
|
||||
## Null Coalesce
|
||||
|
||||
The null coalesce node provides a fallback value in case the original input is null.
|
||||
|
||||
For example, the null coalesce node defines a default fallback audio clip in case the one on the audio source is missing.
|
||||
|
||||

|
@ -0,0 +1,51 @@
|
||||
# Open a graph file
|
||||
|
||||
You can open a graph file from multiple locations, based on the graph type and its source type.
|
||||
|
||||
For information on how to create a new graph file, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
## From the Project window
|
||||
|
||||
To open a graph from the Project window:
|
||||
|
||||
1. [!include[open-project-window](./snippets/vs-open-project-window.md)]
|
||||
|
||||
2. Find the location in your Project window's folders where you saved the graph file you want to edit.
|
||||
|
||||

|
||||
|
||||
3. Double-click the graph file to open it in the Graph window.
|
||||
|
||||
## From the Graph Inspector
|
||||
|
||||
If you have a nested or embedded graph inside another graph file, you can open it from the Graph Inspector.
|
||||
|
||||
1. In the Graph window, select the node that represents the graph you want to edit.
|
||||
This node could be a transition, Super State, Subgraph, or State Unit.
|
||||
|
||||
1. Open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||
2. In the Graph Inspector, select **Edit Graph**.
|
||||
The graph opens in the same Graph window.
|
||||
|
||||

|
||||
|
||||
## From a Script Machine or State Machine
|
||||
|
||||
If you've attached or embedded a graph in a Script Machine or State Machine on a GameObject, you can open the graph from the component on the GameObject:
|
||||
|
||||
1. [!include[open-hierarchy-window](./snippets/vs-open-hierarchy-window.md)]
|
||||
|
||||
1. In the Hierarchy window, select the GameObject that has the Script Machine or State Machine with the graph you want to edit.
|
||||
|
||||
1. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)]
|
||||
|
||||
2. On the Script Machine or State Machine component, select **Edit Graph**.
|
||||
|
||||

|
||||
|
||||
## Next steps
|
||||
|
||||
After you open a graph file, you can add a node to the graph. For more information on how to add a node to a Script Graph, see [Add a node to a Script Graph](vs-add-node-to-graph.md). For more information on how to edit a State Graph, see [Develop logic transitions with State Graphs](vs-state-graphs-intro.md).
|
||||
|
||||
You can also add a [Sticky Note](vs-sticky-notes.md) to add comments to a graph.
|
@ -0,0 +1,49 @@
|
||||
# Add the RenamedFrom attribute to a C# script
|
||||
|
||||
To use nodes generated from a custom C# script in a project after you rename a member, class, struct, type, or enum, add the `[RenamedFrom]` attribute to the relevant API element in the script file. For more information on the `[RenamedFrom]` attribute, see [Refactor a C# script with Visual Scripting](vs-refactoring.md).
|
||||
|
||||
To add the attribute to a C# script:
|
||||
|
||||
<ol>
|
||||
<li><p>[!include[open-project-window](./snippets/vs-open-project-window.md)]</p></li>
|
||||
<li><p>In the Project window, double-click the C# script file you want to refactor. Unity opens the file in the program you specified in your preferences, under <strong>External Script Editor</strong>.</p>
|
||||
<div class="NOTE"><h5>NOTE</h5><p>For more information on script editors in Unity, see <a href="https://docs.unity3d.com/Manual/ScriptingToolsIDEs.html">Integrated development environment (IDE) support</a> in the Unity User Manual.</p></div>
|
||||
</li>
|
||||
<li><p>In your external editor, do the following:</p>
|
||||
<ol type="a">
|
||||
<li><p>Add the <code>[RenamedFrom]</code> attribute above the definition of the part of the script you want to rename.</p></li>
|
||||
<li><p>Add the element's old name as a string to the <code>[RenamedFrom]</code> attribute, as its parameter. For example:</p></li>
|
||||
<pre><code class="lang-C#">
|
||||
using UnityEngine;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
[RenamedFrom("Character")]
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
[RenamedFrom("InflictDamage")]
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
//...
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</ol></li>
|
||||
<li><p>[!include[save-script](./snippets/vs-save-script.md)]</p></li>
|
||||
<li><p>[!include[return-unity](./snippets/vs-return-unity.md)]</p></li>
|
||||
<li><p>[!include[regen-node-library](./snippets/vs-regen-node-library.md)]</p></li>
|
||||
</ol>
|
||||
|
||||
> [!NOTE]
|
||||
> If you change the namespace or namespaces used in your script, you must include the old namespace or namespaces to use the `[RenamedFrom]` attribute.
|
||||
|
||||
## Next steps
|
||||
|
||||
Unity recommends that you leave the attribute in the script file, even after a successful recompile. Nodes that use your C# script no longer have errors related to a missing member, class, struct, type, or enum.
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Refactor a C# script with Visual Scripting](vs-refactor-add-attribute.md)
|
||||
- [Configure project settings](vs-configuration.md)
|
||||
- [Add or remove types from your Type Options](vs-add-remove-type-options.md)
|
||||
- [Custom C# nodes](vs-create-custom-node.md)
|
||||
- [Custom events](vs-custom-events.md)
|
@ -0,0 +1,40 @@
|
||||
# Refactor a C# script with Visual Scripting
|
||||
|
||||
Visual Scripting creates nodes from methods, fields, and properties from C# script in your project. Visual Scripting creates these nodes after you [regenerate your Node Library](vs-configuration.md) and [add any relevant types to your Type Options](vs-add-remove-type-options.md).
|
||||
|
||||
For example, Visual Scripting created the following Take Damage node from a custom C# script that defines the `Player` class.
|
||||
|
||||

|
||||
|
||||
Visual Scripting generated the node with the following code, which creates a `Player` class with a `TakeDamage` member.
|
||||
|
||||
``` C#
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
//...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> You can [create your own custom node](vs-create-custom-node.md) or [create a custom event](vs-custom-events.md) to customize the ports and information displayed on your nodes.
|
||||
|
||||
If you change the name of the `TakeDamage` member in the C# script, Visual Scripting displays an error in Script Graphs that use the Take Damage node.
|
||||
|
||||

|
||||
|
||||
To rename a member, type, class, struct, enum, or other API element that a Visual Scripting node uses in a project, add the `[RenamedFrom]` attribute to the relevant API element in the script file. To avoid issues with Unity's serialization, the `[RenamedFrom]` attribute tells Visual Scripting that an API or one of its elements has been renamed.
|
||||
|
||||
For more information on how to add the `[RenamedFrom]` attribute to a C# script, see [Add the RenamedFrom attribute to a C# script](vs-refactor-add-attribute.md).
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Add the RenamedFrom attribute to a C# script](vs-refactor-add-attribute.md)
|
||||
- [Configure project settings](vs-configuration.md)
|
||||
- [Add or remove types from your Type Options](vs-add-remove-type-options.md)
|
||||
- [Custom C# nodes](vs-create-custom-node.md)
|
||||
- [Custom events](vs-custom-events.md)
|
@ -0,0 +1,22 @@
|
||||
# Use relations to debug
|
||||
|
||||
Relations are a useful tool to understand the dependencies between each port of a node. For example, to get the result of A + B with the Add node, you need to provide a value for A and B. Likewise, before invoking the Log node, you should provide a value for its Message input port.
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
Visual scripting uses this information in the background for Predictive Debugging. For example, if you tried to get the value of A + B without providing a value for A, the node would show up as orange to indicate that it fails in play mode.
|
||||
|
||||

|
||||
|
||||
|
||||
When that happens, you can use the warnings shown in the Graph Inspector to know what is missing.
|
||||
|
||||
|
||||
Relations can also help understand the ports that are required and which ports are optional. For example, in the Get Child node (under fuzzy finder **Codebase** > **Unity Engine** > **Transform**), there is no need to connect the control ports if the goal is to get the transform value output.
|
||||
|
||||
Enable the Relations toggle in the toolbar for the inner connections of each node to be displayed.
|
||||
|
||||
> [!NOTE]
|
||||
> You cannot edit relations. They are predefined for each type of node.
|
@ -0,0 +1,19 @@
|
||||
# Develop application logic with Script Graphs
|
||||
|
||||
Use Script Graphs to create interactions and logic in your project.
|
||||
|
||||
## Create a graph file
|
||||
|
||||
Create a graph file to get started. For more information, see [Create a new graph file](vs-create-graph.md).
|
||||
|
||||
## Add and connect nodes
|
||||
|
||||
After you have a graph file, [add a node](vs-add-node-to-graph.md) or [connect nodes together](vs-creating-connections.md) to build logic.
|
||||
|
||||
## Create Subgraphs
|
||||
|
||||
Reuse logic with [Subgraphs](vs-nesting-add-subgraph.md).
|
||||
|
||||
## Debug your graphs
|
||||
|
||||
You can [use relations](vs-relations.md) to help you debug your scripts, or use Visual Scripting's [predictive debugging](vs-debugging.md) to help you catch problems.
|
@ -0,0 +1,282 @@
|
||||
# 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](#SetScript)
|
||||
- [Has Script Graph](#HasScript)
|
||||
- [Get Script Graph](#GetScript)
|
||||
- [Get Script Graphs](#GetScripts)
|
||||
|
||||
## <a name="SetScript">Set Script Graph</a>
|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Node Parameters</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Container Type</strong></td>
|
||||
<td>Specifies whether the <b>Target</b> is a GameObject or Script Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Enter</strong></td>
|
||||
<td>(Input Trigger) The execution input trigger for the node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-C.png" alt="The letter C in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Target</strong></td>
|
||||
<td>(GameObject or Script Machine) The GameObject or Script Machine where the node sets the <b>Graph</b>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-D.png" alt="The letter D in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(Script Graph Asset) The Script Graph the node sets on the <b>Target</b>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-E.png" alt="The letter E in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Exit</strong></td>
|
||||
<td>(Output Trigger) The execution output trigger.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-F.png" alt="The letter F in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(Script Graph Asset; Optional) Outputs the <b>Graph</b>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### 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__ | |
|
||||
| __Script Machine__ | |
|
||||
|
||||
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.
|
||||
|
||||
## <a name="HasScript">Has Script Graph</a>
|
||||
|
||||
The Has Script Graph node allows you to determine whether a GameObject or Script Machine has a specific Script Graph assigned to it.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Node Parameters</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Container Type</strong></td>
|
||||
<td>Specify whether the <b>Target</b> is a GameObject or Script Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Enter</strong></td>
|
||||
<td>(Input Trigger) The execution input trigger for the node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-C.png" alt="The letter C in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Target</strong></td>
|
||||
<td>(GameObject or Script Machine) The GameObject or Script Machine where the node should check for the <b>Graph</b>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-D.png" alt="The letter D in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(Script Graph Asset) The Script Graph to search for on the GameObject or Script Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-E.png" alt="The letter E in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Exit</strong></td>
|
||||
<td>(Output Trigger) The execution output trigger, which starts execution of the next node in the flow after checking for the specified Script Graph.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-F.png" alt="The letter F in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Has Graph</strong></td>
|
||||
<td>(Boolean) Outputs <code>true</code> if the node found the specified Script Graph, <code>false</code> if not.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### 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__ | |
|
||||
| __Script Machine__ | |
|
||||
|
||||
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](vs-control.md).
|
||||
|
||||
## <a name="GetScript">Get Script Graph</a>
|
||||
|
||||
The Get Script Graph node returns the first Script Graph set on a GameObject.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>GameObject</strong></td>
|
||||
<td>(GameObject) The GameObject where the node should retrieve a set Script Graph.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(Script Graph Asset) Outputs the first or only Script Graph set on the GameObject, or null if there is no set Script Graph.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### 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](#GetScripts).
|
||||
|
||||
## <a name="GetScripts">Get Script Graphs</a>
|
||||
|
||||
The Get Script Graphs node returns a list of all Script Graphs set on a GameObject.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>GameObject</strong></td>
|
||||
<td>(GameObject) The GameObject where the node should retrieve a list of set Script Graphs.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
|
||||
<td><strong>Graphs</strong></td>
|
||||
<td>(List of Script Graph Assets) Outputs a list of all Script Graphs set on the GameObject, or an empty list if there are no set Script Graphs.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### 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.
|
@ -0,0 +1,17 @@
|
||||
# This node
|
||||
|
||||
Use a This node to return a GameObject with a Script Machine component that has the Script Graph. If the Script Machine uses an **Graph** source and multiple GameObjects use the same graph, the returned GameObject can change.
|
||||
|
||||
Many nodes default their target to **This**. For example, the following Transform nodes are the same:
|
||||
|
||||

|
||||
|
||||
Not all nodes support the **This** inline value. Any node that doesn't support the **This** inline value displays **None** instead of **This** in the default value field. For example, the Destroy node displays **None**.
|
||||
|
||||
In these cases, manually specify the connection if you want to use **This**.
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
You can use the This node in a graph even if the graph isn't yet assigned to a GameObject. The This node represents the GameObject that owns the graph at runtime.
|
@ -0,0 +1,260 @@
|
||||
# Configure your preferences
|
||||
|
||||
You can configure specific preferences in Visual Scripting to control the behavior of the [Graph window](vs-interface-overview.md) and your nodes.
|
||||
|
||||
To configure your preferences for Visual Scripting:
|
||||
|
||||
1. Go to **Edit** > **Preferences**.
|
||||
1. Select **Visual Scripting**.
|
||||
|
||||
## Core preferences
|
||||
|
||||
The following preferences control general behaviors across all graph types in Visual Scripting.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Preference</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Dim Inactive Nodes</strong></td>
|
||||
<td colspan="2">Enable <strong>Dim Inactive Nodes</strong> to dim any nodes in the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a> that aren't connected to the logic flow in a graph. This provides you with a visual cue that a dimmed node isn't used in the graph in its current configuration. <br/>Disable <strong>Dim Inactive Nodes</strong> to display all nodes as active, regardless of their connection state. <div class="NOTE"><h5>NOTE</h5><p>You can also control this preference from the Graph toolbar. For more information, see <a href="vs-interface-overview.md#the-graph-toolbar">The interface</a>.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Dim Incompatible Nodes</strong></td>
|
||||
<td colspan="2">Enable <strong>Dim Incompatible Nodes</strong> to dim all nodes that don't have a compatible connection port when you create a new edge. <br/>Disable <strong>Dim Incompatible Nodes</strong> to display all nodes as active for a new edge.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Show Variables Help</strong></td>
|
||||
<td colspan="2">Enable <strong>Show Variables Help</strong> to display a brief explanation of the selected variable scope in the <a href="vs-interface-overview.md#the-blackboard">Blackboard</a>. <br/>Disable <strong>Show Variables Help</strong> to hide these explanations.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Create Scene Variables</strong></td>
|
||||
<td colspan="2">Enable <strong>Create Scene Variables</strong> to automatically create a <strong>Scene Variables</strong> GameObject with a <strong>Variables</strong> component and a Scene Variables script component after you create a <a href="vs-variables.md#variable-scopes">Scene variable</a>. A GameObject with these components is required to use Scene variables in a project. <br/>Disable <strong>Create Scene Variables</strong> to create these components on a GameObject manually.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Show Grid</strong></td>
|
||||
<td colspan="2">Enable <strong>Show Grid</strong> to display a grid on the background of the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a>. <br/>Disable <strong>Show Grid</strong> to hide the grid.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Snap to Grid</strong></td>
|
||||
<td colspan="2">Enable <strong>Snap to Grid</strong> to force nodes to stick or snap to points on a grid in the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a>. <br/>Disable <strong>Snap to Grid</strong> to move nodes freely and disable the snap-to-point behavior.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Pan Speed</strong></td>
|
||||
<td colspan="2">Set a <strong>Pan Speed</strong> to control how quickly the view in the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a> moves when you pan vertically with the scroll wheel.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Drag Pan Speed</strong></td>
|
||||
<td colspan="2">Set a <strong>Drag Pan Speed</strong> to control how quickly the view in the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a> moves when you move a node to the edge of the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Zoom Speed</strong></td>
|
||||
<td colspan="2">Set a <strong>Zoom Speed</strong> to control how quickly the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a> zooms in or zooms out while you change the zoom level in the Graph window. For more information on how to change the zoom level in the Graph Editor, see <a href="vs-control-schemes.md#zoom-inzoom-out">Choose a control scheme</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Overview Smoothing</strong></td>
|
||||
<td colspan="2">Set an <strong>Overview Smoothing</strong> to control how gradually the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a> zooms or pans after you select the <strong>Overview</strong> option in the <a href="vs-interface-overview.md#the-graph-toolbar">Graph toolbar</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Carry Children</strong></td>
|
||||
<td colspan="2">Enable <strong>Carry Children</strong> to move all connected child nodes when you move a parent node in the <a href="vs-interface-overview.md#the-graph-editor">Graph Editor</a>. <br/>Disable <strong>Carry Children</strong> to only move the currently selected node in the Graph Editor. <br/> <div class="NOTE"><h5>NOTE</h5><p>You can also change this setting from the Graph toolbar in the Graph window. For more information, see <a href="vs-interface-overview.md#the-graph-toolbar">The interface</a>.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Disable Playmode Tint</strong></td>
|
||||
<td colspan="2">Enable <strong>Disable Playmode Tint</strong> to display all nodes in the Graph window as normal while the Unity Editor is in Play mode. <br/>Disable <strong>Disable Playmode Tint</strong> to add a tint to all nodes in the Graph window while the Editor is in Play mode. For more information on Play mode, see <a href="https://docs.unity3d.com/Manual/GameView.html">The Game view</a> in the Unity User Manual.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="3"><strong>Control Scheme</strong></td>
|
||||
<td colspan="2">Select a Visual Scripting control scheme. For more information, see <a href="vs-control-schemes.md">Choose a control scheme</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Default</strong></td>
|
||||
<td>Use the Default Visual Scripting control scheme.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Alternate</strong></td>
|
||||
<td>Use the Alternate Visual Scripting control scheme.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Clear Graph Selection</strong></td>
|
||||
<td colspan="2">Enable <strong>Clear Graph Selection</strong> to clear any graph displayed in the Graph window after you select a GameObject with no set graph or graphs. <br/>Disable <strong>Clear Graph Window</strong> to keep the last displayed graph if the selected GameObject has no set graph assets.<br/> <div class="NOTE"><h5>NOTE</h5><p>Visual Scripting always updates the Graph window to display the set graph on a selected GameObject, regardless of your chosen <strong>Clear Graph Selection</strong> setting.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Human Naming</strong></td>
|
||||
<td colspan="2">Enable <strong>Human Naming</strong> to convert all displayed method names from camel case to title case. For example, <code>camelCase</code> becomes <code>Camel Case</code>. <br/>Disable <strong>Human Naming</strong> to leave all names in camel case.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Max Search Results</strong></td>
|
||||
<td colspan="2">Set a <strong>Max Search Results</strong> value to specify the maximum number of search results returned by <a href="vs-interface-overview.md#the-fuzzy-finder">the fuzzy finder</a> after you use the search bar.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Group Inherited Members</strong></td>
|
||||
<td colspan="2">Enable <strong>Group Inherited Members</strong> to group together inherited nodes from a parent or base class to your current search term in <a href="vs-interface-overview.md#the-fuzzy-finder">the fuzzy finder</a>. <br/>For example, an <code>Audio Source</code> is a <code>Component</code>: it has its own specific methods and nodes, but you can interact with it as a <code>Component</code> with <code>Component</code> nodes. While you perform a search in the fuzzy finder, Visual Scripting groups the nodes inherited from <code>Component</code> and displays them in grey. <br/>Disable <strong>Group Inherited Members</strong> to display nodes in the search results without grouping these inherited nodes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Developer Mode</strong></td>
|
||||
<td colspan="2">Enable <strong>Developer Mode</strong> to display additional preferences in the Preferences window and add additional features in the Graph window and other areas of the Unity Editor. For more information on the additional Developer Mode preferences, see <a href="#additional-developer-mode-preferences">Additional Developer Mode preferences</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>AOT Safe Mode</strong></td>
|
||||
<td colspan="2">Enable <strong>AOT Safe Mode</strong> to exclude nodes from search results in <a href="vs-interface-overview.md#the-fuzzy-finder">the fuzzy finder</a> that might cause problems for platforms that require ahead of time (AOT) compilation. For example, Visual Scripting excludes nodes that use the <code>Generic</code> type. <br/>Disable <strong>AOT Safe Mode</strong> to display all nodes and types in the fuzzy finder.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Script Graphs preferences
|
||||
|
||||
The following preferences change the behavior of Script Graphs in the Graph window.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Preference</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Update Nodes Automatically</strong></td>
|
||||
<td><div class="NOTE"><h5>NOTE</h5><p>This feature is experimental.</p></div>Enable <strong>Update Nodes Automatically</strong> to let Visual Scripting automatically update your Node Library when it detects a change in any script inside your project's <strong>Assets</strong> folder. <br/>Disable <strong>Update Nodes Automatically</strong> to manually regenerate your Node Library after you make a change to a script. For more information on how to regenerate your Node Library, see <a href="vs-configuration.md">Configure project settings</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Predict Potential Null References</strong></td>
|
||||
<td>A predictive debugging feature. Enable <strong>Predict Potential Null References</strong> to display warnings about potential <code>null</code> value inputs in your graphs. <br/>Disable <strong>Predict Potential Null References</strong> to disable these warnings. <br/> <div class="NOTE"><h5>NOTE</h5><p>Sometimes, predictive debugging might return false positive results when you enable this setting.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Predict Potential Missing Components</strong></td>
|
||||
<td>A predictive debugging feature. Enable <strong>Predict Potential Missing Components</strong> to display warnings about potential missing components in your graphs, such as a missing node input. <br/>Disable <strong>Predict Potential Missing Components</strong> to disable these warnings. <br/> <div class="NOTE"><h5>NOTE</h5><p>Sometimes, predictive debugging might return false positive results when you enable this setting.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Show Connection Values</strong></td>
|
||||
<td>Enable <strong>Show Connection Values</strong> to display the input and output values sent between nodes while the Editor is in Play mode. This can make it easier to debug your scripts. <br/>Disable <strong>Show Connection Values</strong> to hide these value labels while in Play mode. For more information on Play mode, see <a href="https://docs.unity3d.com/Manual/GameView.html">The Game view</a> in the User Manual. <div class="NOTE"><h5>NOTE</h5><p>You can also control this preference from the Graph toolbar. For more information, see <a href="vs-interface-overview.md#the-graph-toolbar">The interface</a>.</p></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Predict Connection Values</strong></td>
|
||||
<td>Enable <strong>Predict Connection Values</strong> to have the Graph Editor predict what input and output values your graph sends between nodes while the Unity Editor is in Play mode. For example, Visual Scripting would display the value currently set for a variable in your script, though that value might change before it's used by a node. <br/>Disable <strong>Predict Connection Values</strong> to hide these predicted input and output values.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Hide Port Labels</strong></td>
|
||||
<td>Enable <strong>Hide Port Labels</strong> to hide the name labels for node input and output ports. <br/>Disable <strong>Hide Port Labels</strong> to display these name labels.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Animate Control Connections</strong></td>
|
||||
<td>Enable <strong>Animate Control Connections</strong> to display a droplet animation across node control port edges while the Editor is in Play mode. <br/>Disable <strong>Animate Control Connections</strong> to disable the animations. For more information about the different node port types and edges, see <a href="vs-nodes.md">Nodes</a>. For more information on Play mode, see <a href="https://docs.unity3d.com/Manual/GameView.html">The Game view</a> in the User Manual.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Animate Value Connections</strong></td>
|
||||
<td>Enable <strong>Animate Value Connections</strong> to display a droplet animation across node data port edges while the Editor is in Play mode. <br/>Disable <strong>Animate Value Connections</strong> to disable the animations. For more information about the different node port types and edges, see <a href="vs-nodes.md">Nodes</a>. For more information on Play mode, see <a href="https://docs.unity3d.com/Manual/GameView.html">The Game view</a> in the User Manual.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Skip Context Menu</strong></td>
|
||||
<td>Enable <strong>Skip Context Menu</strong> to always open <a href="vs-interface-overview.md#the-fuzzy-finder">the fuzzy finder</a> when you right-click in the Graph Editor. To access the context menu, use Shift+right-click. <br/>Disable <strong>Skip Context Menu</strong> to open the fuzzy finder when you right-click with no nodes or groups selected in the Graph Editor. The context menu opens when you right-click with a node or group selected.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## State Graphs preferences
|
||||
|
||||
The following preferences change the behavior of State Graphs in the Graph window.
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Preference</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="8"><strong>States Reveal</strong></td>
|
||||
<td colspan="2">Use the dropdown to choose when a Script State node displays a list of events from its graph.<br/>
|
||||
If you have many Script State nodes in a State Graph, you might want to change this setting.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Never</strong></td>
|
||||
<td>Script State nodes never display their list of events.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Always</strong></td>
|
||||
<td>Script State nodes always display their list of events.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover</strong></td>
|
||||
<td>Script State nodes only display their list of events when you hover over the node in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover with Alt</strong></td>
|
||||
<td>Script State nodes only display their list of events when you hover over the node while you hold Alt.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>When Selected</strong></td>
|
||||
<td>Script State nodes only display their list of events when you select the node in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover or Selected</strong></td>
|
||||
<td>Script State nodes display their list of events when you hover over the node, or when you select the node in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover with Alt or Selected</strong></td>
|
||||
<td>Script State nodes display their list of events when you hover over the node while you hold Alt, or when you select the node in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="8"><strong>Transitions Reveal</strong></td>
|
||||
<td colspan="2">Use the dropdown to choose when a transition displays a list of events from its graph.<br/>
|
||||
If you have many transitions in a State Graph, you might want to change this setting.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Never</strong></td>
|
||||
<td>Transitions never display a list of events.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Always</strong></td>
|
||||
<td>Transitions always display a list of events.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover</strong></td>
|
||||
<td>Transitions only display a list of events when you hover over the transition in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover with Alt</strong></td>
|
||||
<td>Transitions only display a list of events when you hover over the transition while you hold Alt.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>When Selected</strong></td>
|
||||
<td>Transitions only display a list of events when you select the transition in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover or Selected</strong></td>
|
||||
<td>Transitions display a list of events when you hover over the transition, or when you select the transition in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>On Hover with Alt or Selected</strong></td>
|
||||
<td>Transitions display a list of events when you hover over the transition while you hold Alt, or when you select the transition in the Graph window.</td>
|
||||
<tr>
|
||||
<td><strong>Transitions End Arrow</strong></td>
|
||||
<td colspan="2">Enable <strong>Transitions End Arrow</strong> to add an arrow to the end of each transition edge in a State Graph. Disable <strong>Transitions End Arrow</strong> to display edges between transitions as simple lines. <br/>If you have many transitions in your State Graphs, you might want to disable this setting.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Animate Transitions</strong></td>
|
||||
<td colspan="2">Enable <strong>Animate Transitions</strong> to display a droplet animation across transition edges when the Editor is in Play mode. Disable <strong>Animate Transitions</strong> to disable the animations. For more information on Play mode, see <a href="https://docs.unity3d.com/Manual/GameView.html">The Game view</a> in the User Manual.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Additional Developer Mode preferences
|
||||
|
||||
> [!NOTE]
|
||||
> You can only access the following preferences after you have enabled **Developer Mode* in your [Core preferences](#core-preferences).
|
||||
|
||||
These Developer Mode preferences provide help with developing extensions or custom nodes for Visual Scripting. Their continued support in the Visual Scripting package isn't guaranteed.
|
||||
|
||||
|**Preference** |**Description** |
|
||||
|:---|:---|
|
||||
|**Debug** | Enable **Debug** to add additional logging and visual overlays to help you debug element rendering in the Graph window. For example, if you created a custom node, use this setting to help debug your UI. <br/>Disable **Debug** to disable the logging and hide these overlays.|
|
||||
|**Track Metadata State** | Enable **Track Metadata State** to add more information to logging. This can assist in debugging. <br/>Disable **Track Metadata State** to hide this additional information.|
|
||||
|**Debug Inspector UI** | Enable **Debug Inspector UI** to add more overlays and additional details. The information available is greater than what Visual Scripting provides with the **Debug** setting, and affects more areas of the Editor's UI. Only enable this setting if you need more in-depth debugging feedback. <br/>Disable **Debug Inspector UI** to hide this information.|
|
@ -0,0 +1,15 @@
|
||||
# Develop logic transitions with State Graphs
|
||||
|
||||
You can use State Graphs to change behaviors of GameObjects based on specific conditions.
|
||||
|
||||
## Create a new state
|
||||
|
||||
After you [create a new graph file](vs-create-graph.md) for a State Graph, you can [create states](vs-create-state.md) to tell Visual Scripting what a GameObject does, and when.
|
||||
|
||||
## Create a transition
|
||||
|
||||
Use [transitions](vs-transitions.md) to tell Visual Scripting when a GameObject changes states. There's no restriction on how many transitions you can create.
|
||||
|
||||
## State Unit nodes
|
||||
|
||||
You can use a [State Unit node](vs-nesting-state-unit-node.md) to nest a State Graph inside a Script Graph.
|
@ -0,0 +1,282 @@
|
||||
# State Graph nodes
|
||||
|
||||
Visual scripting has four nodes that you can use to identify and manipulate the State Graphs assigned to a GameObject and its State Machines:
|
||||
|
||||
- [Set State Graph](#SetState)
|
||||
- [Has State Graph](#HasState)
|
||||
- [Get State Graph](#GetState)
|
||||
- [Get State Graphs](#GetStates)
|
||||
|
||||
## <a name="SetState">Set State Graph</a>
|
||||
|
||||
You can use the Set State Graph node to assign a State Graph to a specific State Machine, or to the first State Machine attached to a specific GameObject.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Node Parameters</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Container Type</strong></td>
|
||||
<td>Specifies whether the <b>Target</b> is a GameObject or State Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Enter</strong></td>
|
||||
<td>(Input Trigger) The execution input trigger for the node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-C.png" alt="The letter C in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Target</strong></td>
|
||||
<td>(GameObject or State Machine) The GameObject or State Machine where the node sets the <b>Graph</b>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-D.png" alt="The letter D in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(State Graph Asset) The State Graph the node sets on the <b>Target</b>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-E.png" alt="The letter E in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Exit</strong></td>
|
||||
<td>(Output Trigger) The execution output trigger.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-F.png" alt="The letter F in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(State Graph Asset; Optional) Outputs the <b>Graph</b>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Setting the required node parameters and inputs
|
||||
|
||||
The Set State 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 State Machine attached to that GameObject.
|
||||
|
||||
- If you choose **State Machine**, the node expects to receive a State Machine, and you can specify the exact State Machine where you want to set your State 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__ | |
|
||||
| __State Machine__ | |
|
||||
|
||||
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 State Graph node.
|
||||
|
||||
The other two ports collect the Set State Graph node's required input data:
|
||||
|
||||
- The **Target**, or the GameObject or State Machine where you want to set a State Graph.
|
||||
|
||||
- The **Graph**, or the State Graph to assign to the GameObject or State Machine.
|
||||
|
||||
### Outputs
|
||||
|
||||
The Set State 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 State Graph node has finished.
|
||||
|
||||
The second port, **Graph**, can output the State Graph that you assigned using the node.
|
||||
|
||||
## <a name="HasState">Has State Graph</a>
|
||||
|
||||
The Has State Graph node allows you to determine whether a GameObject or State Machine has a specific State Graph assigned to it.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Node Parameters</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Container Type</strong></td>
|
||||
<td>Specify whether the <b>Target</b> is a GameObject or State Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Enter</strong></td>
|
||||
<td>(Input Trigger) The execution input trigger for the node.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-C.png" alt="The letter C in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Target</strong></td>
|
||||
<td>(GameObject or State Machine) The GameObject or State Machine where the node should check for the <b>Graph</b>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-D.png" alt="The letter D in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(State Graph Asset) The State Graph to search for on the GameObject or State Machine.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-E.png" alt="The letter E in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Exit</strong></td>
|
||||
<td>(Output Trigger) The execution output trigger, which starts execution of the next node in the flow after checking for the specified State Graph.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-F.png" alt="The letter F in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Has Graph</strong></td>
|
||||
<td>(Boolean) Outputs <code>true</code> if the node found the specified State Graph, <code>false</code> if not.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Setting the required node parameters and inputs
|
||||
|
||||
The Has State 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 State Machine attached to that GameObject.
|
||||
|
||||
- If you choose **State Machine**, the node expects to receive a State Machine, and you can specify the exact State Machine where you want to check for the State 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__ | |
|
||||
| __State Machine__ | |
|
||||
|
||||
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 State Graph node.
|
||||
|
||||
The other two ports collect the Has State Graph node's required input data:
|
||||
|
||||
- The **Target**, or the GameObject or State Machine where you want to check for a State Graph.
|
||||
|
||||
- The **Graph**, or the State Graph to search for on the GameObject or State Machine.
|
||||
|
||||
### Outputs
|
||||
|
||||
The Has State Graph node returns `true` if it finds the specified State Graph. Otherwise, it returns `false`.
|
||||
|
||||
You can use a control node connected to the Has State Graph's output port to change what your script does next, based on the result from Has State Graph. For more information about control nodes, see [Control nodes](vs-control.md).
|
||||
|
||||
## <a name="GetState">Get State Graph</a>
|
||||
|
||||
The Get State Graph node returns the first State Graph set on a GameObject.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>GameObject</strong></td>
|
||||
<td>(GameObject) The GameObject where the node should retrieve a set State Graph.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Graph</strong></td>
|
||||
<td>(State Graph Asset) Outputs the first or only State Graph set on the GameObject, or null if there is no set State Graph.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Setting the required node parameters and inputs
|
||||
|
||||
The Get State 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 State 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 State Graph node has a single output port, located on the right side. The output port returns the GameObject's first set State Graph, or `null`, if there is no set State Graph.
|
||||
|
||||
> [!NOTE]
|
||||
> The Get State Graph node returns only the first State Graph set on a GameObject. To return all State Graphs set on a GameObject, use the [Get State Graphs node](#GetStates).
|
||||
|
||||
## <a name="GetStates">Get State Graphs</a>
|
||||
|
||||
The Get State Graphs node returns a list of all State Graphs set on a GameObject.
|
||||
|
||||

|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><strong>Item</strong></th>
|
||||
<th><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<td colspan="2"><strong>Input Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>GameObject</strong></td>
|
||||
<td>(GameObject) The GameObject where the node should retrieve a list of set State Graphs.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Output Ports</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set State Graph node image."></td>
|
||||
<td><strong>Graphs</strong></td>
|
||||
<td>(List of State Graph Assets) Outputs a list of all State Graphs set on the GameObject, or an empty list if there are no set State Graphs.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Setting the required node parameters and inputs
|
||||
|
||||
The Get State 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 State 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 State Graphs node has a single output port, located on the right side. The output port returns a list of all set State Graphs for the GameObject, or an empty list, if there are no set State Graphs.
|
@ -0,0 +1,86 @@
|
||||
# Add comments to a graph
|
||||
|
||||
Use Sticky Notes to add comments to a graph. Sticky Notes can:
|
||||
|
||||
- Describe how a section of your graph works.
|
||||
- Leave a note for yourself or others who might work on your Unity project.
|
||||
|
||||
You can add text to the title and body of a Sticky Note. You can use Sticky Notes in Script Graphs and State Graphs.
|
||||
|
||||

|
||||
|
||||
## Add a Sticky Note to a graph
|
||||
|
||||
To add a Sticky Note to a graph:
|
||||
|
||||
1. [!include[open-graph](./snippets/vs-open-graph.md)]
|
||||
1. Do one of the following:
|
||||
- [!include[open-fuzzy-finder](./snippets/vs-open-fuzzy-finder.md)] Select **Sticky Note**.
|
||||
- With no items selected in the graph, right-click an empty space in the Graph Editor. Select **Create Sticky Note**.
|
||||
|
||||
|
||||
## Edit a Sticky Note
|
||||
|
||||
To edit text in the title or body of a Sticky Note:
|
||||
|
||||
1. [!include[open-graph](./snippets/vs-open-graph.md)]
|
||||
1. Do one of the following:
|
||||
- To edit the title of the Sticky Note, double-click the title.
|
||||
- To edit the body of the Sticky Note, double-click the body.
|
||||
1. Enter the new text for the Sticky Note.
|
||||
1. Click anywhere in the Graph Editor to close the Sticky Note text editor.
|
||||
|
||||
> [!TIP]
|
||||
> You can also edit the text in a Sticky Note with the [Graph Inspector](vs-interface-overview.md#the-graph-inspector):
|
||||
> 1. Select the Sticky Note you want to edit.
|
||||
> 1. [!include[open-graph-inspector](./snippets/vs-open-graph-inspector.md)]
|
||||
> 1. Do one of the following:
|
||||
> - To edit the title of the Sticky Note, select the title.
|
||||
> - To edit the body of the Sticky Note, select **(Body)**.
|
||||
> 1. Enter the new text for the Sticky Note.
|
||||
|
||||
## Move a Sticky Note
|
||||
|
||||
To move a Sticky Note to a new location in a graph:
|
||||
|
||||
1. [!include[open-graph](./snippets/vs-open-graph.md)]
|
||||
1. Click and drag the Sticky Note to a new location.
|
||||
|
||||
## Delete a Sticky Note
|
||||
|
||||
To delete a Sticky Note from a graph:
|
||||
|
||||
1. [!include[open-graph](./snippets/vs-open-graph.md)]
|
||||
1. Do one of the following:
|
||||
- Right-click a Sticky Note and select **Delete**.
|
||||
- Select a Sticky Note and press Delete (Del).
|
||||
|
||||
|
||||
## Resize a Sticky Note
|
||||
|
||||
To change the size of a Sticky Note in a graph:
|
||||
|
||||
1. [!include[open-graph](./snippets/vs-open-graph.md)]
|
||||
1. Click and drag a corner of a Sticky Note.
|
||||
|
||||
|
||||
## Change the color of a Sticky Note
|
||||
|
||||
To change the color theme for a Sticky Note:
|
||||
|
||||
1. [!include[open-graph](./snippets/vs-open-graph.md)]
|
||||
1. Select the Sticky Note you want to edit.
|
||||
1. [!include[open-graph-inspector](./snippets/vs-open-graph-inspector.md)]
|
||||
1. Select a **Color Theme**:
|
||||
- **Classic**
|
||||
- **Black**
|
||||
- **Dark**
|
||||
- **Orange**
|
||||
- **Green**
|
||||
- **Blue**
|
||||
- **Red**
|
||||
- **Purple**
|
||||
- **Teal**
|
||||
|
||||
|
||||

|
@ -0,0 +1,105 @@
|
||||
# Time nodes
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Time nodes include timer, cooldown and wait nodes.
|
||||
|
||||
## Wait
|
||||
|
||||
Wait nodes delay the execution of the rest of the script. The delay can be a set amount of seconds or a condition that must be fulfilled before moving on.
|
||||
|
||||
Asynchronicity (delayed execution) in Unity is handled by [coroutines](https://docs.unity3d.com/Manual/Coroutines.html) (not multithreading). You need to inform visual scripting to run the script as a coroutine in order to support wait nodes. To do this enable the **Coroutine checkbox** on the initial event that starts the script. Do this in the graph inspector.
|
||||
|
||||

|
||||
|
||||
A small dual-arrow icon appears on the event, indicating that it runs as a coroutine.
|
||||
|
||||
If the coroutine checkbox is not enabled, an error at runtime indicates a port 'can only be triggered in a coroutine' when reaching a wait node.
|
||||
|
||||
All wait nodes are also used inside loops and sequences.
|
||||
|
||||
### Wait For Seconds
|
||||
|
||||
The Wait For Seconds node is the simplest and most common wait node. It delays the execution by a certain number of seconds.
|
||||
|
||||
|
||||

|
||||
|
||||
### Wait Until
|
||||
|
||||
The Wait Until node stops execution until a given condition is met. For example, you could wait until an object is close enough.
|
||||
|
||||
|
||||

|
||||
|
||||
### Wait While
|
||||
|
||||
The Wait While node is the opposite of the Wait Until node: it stops execution as long as a given condition is met. For example, you can wait while an object is out of range.
|
||||
|
||||
|
||||

|
||||
|
||||
### Wait For Frame
|
||||
|
||||
As the name implies, Wait For End Of Frame and Wait For Next Frame nodes delays execution until a specific point in Unity's update loop is met. For more information, see: [Execution Order of Events](https://docs.unity3d.com/Manual/ExecutionOrder.html).
|
||||
|
||||
### Wait For Script
|
||||
|
||||
The Wait For Script node delays execution until all input scripts have been entered at least once. It's a useful way of grouping conditions that occur over multiple events or frames. In other languages, this concept is sometimes called "promises".
|
||||
|
||||
## Cooldown
|
||||
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
The Cooldown node implements a time restriction when the input script can only be triggered a limited number of times.
|
||||
|
||||
When the cooldown is available, the input script gets transferred to the Ready port. When it is not, it gets transferred to the Not Ready port.
|
||||
|
||||
The Duration port determines how long it takes for the cooldown to become available again. Checking **Unscaled** makes it ignore the [time scale](https://docs.unity3d.com/ScriptReference/Time-timeScale.html).
|
||||
|
||||
The Tick port gets called at every frame while a cooldown is active. It is a good place to update any GUI code that show an indicator of the remaining duration until the action can be called again. In order to get that value, you have two options:
|
||||
|
||||
- Remaining, which returns the number of seconds until ready, and
|
||||
- Remaining %, which returns a value between 0 and 1, respectively from ready to not ready.
|
||||
|
||||
As soon as the cooldown is ready, the Completed port is triggered. There is no need to constantly pass input script for this port to get triggered.
|
||||
|
||||
Finally, you can force the cooldown to become ready and reset its internal timer by triggering the Reset port.
|
||||
|
||||
For example, a simple cooldown firing mechanic with a masked sprite and text that indicates how much time is remaining until it can fire again.
|
||||
|
||||
|
||||

|
||||
|
||||
## Timer
|
||||
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
The Timer node implements and monitors a time pausable progression.
|
||||
|
||||
The Duration port determines how long it takes for the cooldown to become available again. Checking Unscaled makes it ignore the [time scale](https://docs.unity3d.com/ScriptReference/Time-timeScale.html).
|
||||
|
||||
A timer is started by triggering the Start input, which in turn triggers the Started output.
|
||||
|
||||
It can be paused and resumed with the Pause and Resume inputs, or it can alternate between these states with the Toggle input.
|
||||
|
||||
The Tick port gets called at every frame while a timer is active. In order to get the time measurements, you have two options:
|
||||
|
||||
- Elapsed, which returns the time since the timer was started, or
|
||||
- Remaining, which returns the time until the timer completes.
|
||||
|
||||
You can get each of these measurements in absolute number of seconds, or in %, which returns a value between 0 and 1. This is useful for lerping.
|
||||
|
||||
As soon as the timer finishes, the Completed port is triggered.
|
||||
|
||||
For example, a simple autodestroy mechanic on a sprite that is progressively colored red before being destroyed.
|
||||
|
||||
|
||||

|
@ -0,0 +1,22 @@
|
||||
# Transitions
|
||||
|
||||
A transition is a connection between State nodes in a State Graph. A transition has a Script Graph that tells Visual Scripting when to switch states in a State Graph. A special transition type, called a self transition, can make a state transition to itself.
|
||||
|
||||
You can embed the Script Graph for a transition in the Transition node itself, or link to an external graph asset file.
|
||||
|
||||
Use Event nodes and a Trigger Transition node in the Script Graph you attach to a transition. These nodes specify which event or events must occur to trigger a change of state in your parent State Graph.
|
||||
|
||||
For example, the following transition Script Graph switches states after a GameObject with the Player tag enters a trigger Collider.
|
||||
|
||||

|
||||
|
||||
Any transition nodes with a transition Script Graph display the name of the event in the graph that triggers the state change. For example, the following parent State Graph displays the graph from the previous example as an **On Trigger Enter** Transition node.
|
||||
|
||||

|
||||
|
||||
If you've assigned a name to a transition Script Graph, the assigned name appears on the Transition node.
|
||||
|
||||
> [!TIP]
|
||||
> To reduce the space taken up by transition nodes in a State Graph, you can hide their name labels. For more information, see [Configure your preferences](vs-set-preferences.md#state-graphs-preferences).
|
||||
|
||||
You can create any number of transitions between states in a State Graph. For more information on how to create transitions, see [Create a transition between states](vs-creating-transition.md).
|
@ -0,0 +1,114 @@
|
||||
# Object types
|
||||
|
||||
All scripting in Unity is based on the C# programming language. C# is a "strongly typed" language. This means that all data and objects in Visual Scripting have a specific type. For example, a variable can be a number with an `integer` type, or the object provided by a node's output port can be a `GameObject`.
|
||||
|
||||
Types help the computer run Visual Scripting code. Visual Scripting's behavior might not depend on the object type you give a node as an input, but sometimes, an object's type is important.
|
||||
|
||||
For example, to add a new variable in the Blackboard, you must specify the variable's type to assign it a value. When you make a new edge in the Graph Editor, some nodes might have ports that only allow a connection if the data input is the correct type.
|
||||
|
||||
Choose the type for an object with the Type menu. For example, you can choose the type for a Data Input port on a Script Graph with the Type menu from the [Graph Inspector](vs-interface-overview.md#the-graph-inspector).
|
||||
|
||||

|
||||
|
||||
Enter a search term in the Type menu to find a specific object type. You can also navigate through the namespaces listed in the Type menu to find a type.
|
||||
|
||||
Visual Scripting identifies namespaces in the Type menu with an arrow (>). Select any namespace to view the other namespaces or available types within that namespace.
|
||||
|
||||
## Common object types
|
||||
|
||||
Unity has hundreds of types. You can also add your own custom types. For more information on custom types, see [Custom types](vs-custom-types.md).
|
||||
|
||||
The following table includes some commonly used types in Visual Scripting.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Type</strong></th>
|
||||
<th colspan="2"><strong>Description</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Float</strong></td>
|
||||
<td colspan="2">A float is a numeric value, with or without decimal places. <br/>For example, <code>0.25</code> or <code>13.1</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Integer</strong></td>
|
||||
<td colspan="2">An integer is a numeric value without decimal places. <br/>For example, <code>3</code> or <code>200</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Boolean</strong></td>
|
||||
<td colspan="2"> A Boolean is a <code>true</code> or <code>false</code> value. Use a Boolean to create logic in a Script Graph and for toggles. <br/>For example, a Script Graph can trigger an event only if a condition is <code>true</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>String</strong></td>
|
||||
<td colspan="2">A string is a sequence of characters or piece of text. <br/>For example, <code>string</code>, <code>string123</code>, and <code>s</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Char</strong></td>
|
||||
<td colspan="2">A char is a single alphanumeric character from a string. <br/>For example, <code>s</code> or <code>1</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Enum</strong></td>
|
||||
<td colspan="2">An enum is a finite enumeration of options. Enums are usually represented as dropdowns. <br/>For example, a <strong>Force Mode</strong> enum can have a value of either <code>Force</code>, <code>Impulse</code>, <code>Acceleration</code>, or <code>Velocity Change</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan="4"><strong>Vector</strong></td>
|
||||
<td colspan="2">A vector represents a set of float coordinates. Unity uses vectors for positions or directions.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Vector 2</strong></td>
|
||||
<td>A Vector 2 has X and Y values. You can use a Vector 2 for coordinates in 2D spaces.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Vector 3</strong></td>
|
||||
<td>A Vector 3 has X, Y, and Z values. You can use a Vector 3 for coordinates in 3D spaces.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Vector 4</strong></td>
|
||||
<td>A Vector 4 has X, Y, Z, and W values. You can use a Vector 4 for coordinates in 4D spaces, such as parameters for shaders.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>GameObject</strong></td>
|
||||
<td colspan="2">A GameObject is the basic entity used in Unity scenes. All GameObjects have a name, a transform for their position and rotation in the scene, and a list of components.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>List</strong></td>
|
||||
<td colspan="2">A list is an ordered collection of elements. The elements in a list can each have their own type or all have the same type. <br/>Visual Scripting indexes items in a list with the first position at 0. This means that the first element of a list is at the <code>0</code> index of the list. The second item is at the <code>1</code> index, the third is at the <code>2</code> index, and so on.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Dictionary</strong></td>
|
||||
<td colspan="2">A dictionary is a collection of elements. Each element has a unique key and a value. Use a key to access and assign the values for an element in a dictionary. <br/>For example, you can use a dictionary to organize the names and ages of a group of people. The person's name is the key to the value of their age. A single element in the dictionary can be <code>John</code> and <code>33</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Object</strong></td>
|
||||
<td colspan="2">An Object is a special type in Unity. If a data input port on a node has its type set to <code>Object</code>, the node doesn't need a specific type as an input.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Supported type conversions
|
||||
|
||||
Visual Scripting can automatically convert some data types passed between nodes. For example, the following graph gets the Transform from a child GameObject of the current GameObject, and triggers an Animator Controller to play an animation. Visual Scripting converts the Transform component sent by the Transform Get Child node to the Animator Controller component on the same GameObject.
|
||||
|
||||

|
||||
|
||||
Visual Scripting can automatically perform the following type conversions:
|
||||
|
||||
- Number to Number (for example, you can convert an integer to a float, such as 5 to 5.0, or 5.0 to 5)
|
||||
|
||||
- Base class to child class
|
||||
|
||||
- Child class to base class
|
||||
|
||||
- Custom operators (for example, you can convert a Vector 2 to a Vector 3)
|
||||
|
||||
- GameObject to a component (for example, a GameObject to its Rigidbody component)
|
||||
|
||||
- Component to GameObject (for example, a Rigidbody component to its GameObject)
|
||||
|
||||
- Component to component on the same GameObject (for example, a Rigidbody component to a Transform component)
|
||||
|
||||
- Enum to array
|
||||
|
||||
- Enum to list
|
@ -0,0 +1,15 @@
|
||||
# Update Visual Scripting
|
||||
|
||||
> [!TIP]
|
||||
> Back up your data before you update to a new version of Visual Scripting. For more information on how to back up your Visual Scripting assets and settings, see [Create or restore a backup](vs-create-restore-backups.md).
|
||||
|
||||
Before you update, confirm that the version of Visual Scripting is compatible with your current project and needs. For example, you shouldn't use a Preview version of Visual Scripting in a production environment. For more information on package states and the package lifecycle in Unity, see the [Package state and lifecycle](https://docs.unity3d.com/Manual/upm-lifecycle.html) in the Unity User Manual.
|
||||
|
||||
To update your current version of Visual Scripting:
|
||||
|
||||
1. Go to **Window** > **Package Manager**.
|
||||
2. In the **Packages** drop-down menu, select **In Project**.
|
||||
3. In your list of packages, select **Visual Scripting**.
|
||||
4. Select **Update to `X.X.X`**, where `X.X.X` is the newest available version of Visual Scripting.
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
# Use a custom type
|
||||
|
||||
Visual Scripting supports every class and struct type available in Unity. By default, the most common are available in [the fuzzy finder](vs-interface-overview.md#the-fuzzy-finder). Add additional Unity assemblies, such as custom types and classes, through your [project settings](vs-configuration.md).
|
||||
|
||||
You must write some additional code to use a custom type or class in a graph. You can't assign a value to a variable with a custom type from Unity's [Inspector window](https://docs.unity3d.com/Manual/UsingTheInspector.html), or initialize it from inside the Unity Editor if this additional code isn't available. You must assign a default value for a custom type through the Inspector window to use that type for a variable in Visual Scripting.
|
||||
|
||||
You have two options to enable variable assignment and initialization:
|
||||
|
||||
- If you have access to the source code, you can add the `[Inspectable]` attribute to the classes and fields that you want to display and modify in the Editor.
|
||||
- If you don't have access to the source code, you must create a custom PropertyDrawer and generate the required property provider scripts.
|
||||
|
||||
## Add the [Inspectable] attribute
|
||||
|
||||
Add the `[Inspectable]` attribute to the code for your custom class to display its available properties in the Inspector window and Visual Scripting's [Graph Inspector](vs-interface-overview.md#the-graph-inspector). You can't view your classes and fields in the Inspector window without the `[Inspectable]` attribute.
|
||||
|
||||
Unity provides a basic UI for your types in the Inspector window, which might not give the aesthetic results you want. If you or your users want to configure a property for a custom type with a slider, for example, don't use the `[Inspectable]` attribute method. For more information on how to add the `[Inspectable]` attribute to a custom class, see [Add the Inspectable attribute to the source code for a custom type](vs-add-inspectable-attribute-custom-types.md).
|
||||
|
||||
## Create a custom PropertyDrawer
|
||||
|
||||
Create a custom PropertyDrawer to choose how to display each property for a custom class in the Inspector window.
|
||||
|
||||
Without access to the source code, you must create a PropertyDrawer to interact with custom-typed variables in Visual Scripting. If you see an error in the Unity Editor's Inspector window when you try to use a type from a third-party package, you must create a custom PropertyDrawer.
|
||||
|
||||
> [!NOTE]
|
||||
> If you are a package developer, or plan to provide your custom classes and types to other users and want those types to be available in Visual Scripting, create a custom PropertyDrawer to get the best results for your users.
|
||||
|
||||
For more information on how to create a custom PropertyDrawer, see [Create a custom PropertyDrawer for a custom type](vs-create-custom-drawer.md).
|
||||
|
||||
After you create a custom PropertyDrawer for a custom type, you must generate the necessary property provider scripts. For more information, see the **Generate** option in [Configure project settings](vs-configuration.md).
|
||||
|
@ -0,0 +1,149 @@
|
||||
# Variables API
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
Visual scripting provides an easy API to handle variables, to get or set their value and verify if they are defined. All these operations are available from the Variables class.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
Variables.Application.Set("score", 100);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Usings
|
||||
|
||||
Add the following usings to your C# script to access the API:
|
||||
|
||||
```
|
||||
using Unity.VisualScripting;
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Scopes
|
||||
|
||||
### Graph
|
||||
|
||||
To access variables on a graph, create a graph reference. This is basically a path to the nested graph from its root machine.
|
||||
|
||||
To get the root graph on a machine:
|
||||
|
||||
```
|
||||
var graphReference = GraphReference.New(flowMachine, true);
|
||||
```
|
||||
|
||||
To access nested graphs, pass their parent nodes as additional parameters:
|
||||
|
||||
```
|
||||
var graphReference = GraphReference.New(flowMachine, new IGraphParentElement[] { subGraph }, true);
|
||||
```
|
||||
|
||||
To pass a graph reference:
|
||||
|
||||
```
|
||||
Variables.Graph(graphReference)
|
||||
```
|
||||
|
||||
### Object
|
||||
|
||||
To access variables on an object:
|
||||
|
||||
```
|
||||
Variables.Object(gameObject)
|
||||
```
|
||||
|
||||
### Scene
|
||||
|
||||
To access scene variables, do one of the following:
|
||||
|
||||
```
|
||||
Variables.Scene(scene)
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
Variables.Scene(gameObjectInScene)
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
Variables.ActiveScene
|
||||
```
|
||||
|
||||
### Application
|
||||
|
||||
To access application variables:
|
||||
|
||||
```
|
||||
Variables.Application
|
||||
```
|
||||
|
||||
### Saved
|
||||
|
||||
To access saved variables:
|
||||
|
||||
```
|
||||
Variables.Saved
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Operations
|
||||
|
||||
In these examples, the lowercase scope refers to one of the previous scopes.
|
||||
|
||||
### Get
|
||||
|
||||
To get the value of a variable, use the Get method with a name parameter:
|
||||
|
||||
```
|
||||
scope.Get("name");
|
||||
```
|
||||
|
||||
Note that variables are not strongly typed; they need to be cast manually. For example:
|
||||
|
||||
```
|
||||
int health = (int)Variables.Object(player).Get("health")
|
||||
```
|
||||
|
||||
### Set
|
||||
|
||||
To set the value of a variable, use the Set method with the name and value parameters:
|
||||
|
||||
```
|
||||
scope.Set("name", value);
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
Variables.Object(player).Set("health", 100);
|
||||
```
|
||||
|
||||
Because variables are not strongly typed, pass any value to the second parameter, even if the variable currently is of a different type.
|
||||
|
||||
> [!NOTE]
|
||||
> Using the set method with a variable name that does not yet exist defines a new variable.
|
||||
|
||||
### Is Defined
|
||||
|
||||
To check if a variable is defined, use the IsDefined method with a name parameter:
|
||||
|
||||
```
|
||||
scope.IsDefined("name");
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
if (Variables.Application.IsDefined("score"))
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
@ -0,0 +1,219 @@
|
||||
# Variables node
|
||||
|
||||
> [!NOTE]
|
||||
> For versions 2019/2020 LTS, download the Visual Scripting package from the [Unity Asset Store](https://assetstore.unity.com/packages/tools/visual-bolt-163802).
|
||||
|
||||
There are six kinds of [variable](vs-variables.md) nodes. Each of these variable nodes has three object nodes:
|
||||
|
||||
* Get, to retrieve the value of the variable
|
||||
* Set, to assign a new value to the variable
|
||||
* Is Defined, to check whether the variable is defined
|
||||
|
||||
They are located under the Variables category in the fuzzy finder.
|
||||
|
||||
|
||||
Variable nodes are teal colored.
|
||||
|
||||
## Dynamic Typing
|
||||
|
||||
For get / set nodes, variables are not statically typed, meaning their type can change at runtime. Their type displays as an object when defined from the blackboard window.
|
||||
|
||||
### Get Variable
|
||||

|
||||
|
||||
The get variable node requires the name of the variable as an input and returns the **Value** as an output.
|
||||
|
||||
### Set Variable
|
||||

|
||||
|
||||
|
||||
The set variable nodes require the name of the variable and the new value assigned to it as inputs. For convenience in layouting, it returns this same value as an output.
|
||||
|
||||
Connect the control input port to indicate when the variable should be assigned and, optionally, the control output port to indicate what to do after.
|
||||
|
||||
Using a set node with a variable name that doesn't yet exist creates the variable.
|
||||
|
||||
### Has Variable
|
||||
|
||||
The Has Variable nodes require the name of the variable as an input and returns an Is Defined boolean as an output. They're useful to check if a variable has been created, and often, provide a fallback value if it hasn't.
|
||||
|
||||

|
||||
|
||||
|
||||
Do the same thing more easily by checking the Fallback box in the graph inspector for a Get Variable node. This adds a Fallback input to the node that is returned if the variable hasn't been defined:
|
||||
|
||||
|
||||

|
||||
|
||||
## Dynamic Variables
|
||||
|
||||
As the name of the variable is a standard value input port, connect it to any other port that returns a string. Refer to "dynamic variables", that is, variables whose reference might change during play mode.
|
||||
|
||||
## Object Variables
|
||||
|
||||
Object variable nodes require an additional input for the Source. That port indicates which game object the variable you're referring to is defined. When left to its default value, they look on the current object (self).
|
||||
|
||||
For example, the Get Variable node gets the value of the health variable on the player2 object.
|
||||
|
||||

|
||||
|
||||
## Dropdowns
|
||||
|
||||
The kind and the name dropdowns can quickly configure the variable nodes. The name suggestions are contextual and are based on the existing variables of this kind and on the other variable nodes in the current graph.
|
||||
|
||||

|
||||
|
||||
## Drag and Drop
|
||||
|
||||
Drag and drop items from the blackboard window directly into the graph to create matching nodes.
|
||||
|
||||
* By default, a Get node is created.
|
||||
* If the Alt key is held, a Set node is created.
|
||||
* If the Shiftkey is held, an Is Defined node is created.
|
||||
|
||||
## Variables API
|
||||
|
||||
Visual scripting provides an easy API to handle variables, to get or set their value and verify if they are defined. All these operations are available from the Variables class.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
Variables.Application.Set("score", 100);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### Usings
|
||||
|
||||
Add the following usings to your C# script to access the API:
|
||||
|
||||
```
|
||||
using Unity.VisualScripting;
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Scope
|
||||
|
||||
### Graph
|
||||
|
||||
To access variables on a graph, create a graph reference. This is basically a path to the nested graph from its root machine.
|
||||
|
||||
To get the root graph on a machine:
|
||||
|
||||
```
|
||||
var graphReference = GraphReference.New(flowMachine, true);
|
||||
```
|
||||
|
||||
To access nested graphs, pass their parent nodes as additional parameters:
|
||||
|
||||
```
|
||||
var graphReference = GraphReference.New(flowMachine, new IGraphParentElement[] { superUnit }, true);
|
||||
```
|
||||
|
||||
To pass a graph reference:
|
||||
|
||||
```
|
||||
Variables.Graph(graphReference)
|
||||
```
|
||||
|
||||
### Object
|
||||
|
||||
To access variables on an object:
|
||||
|
||||
```
|
||||
Variables.Object(gameObject)
|
||||
```
|
||||
|
||||
### Scene
|
||||
|
||||
To access scene variables, do one of the following:
|
||||
|
||||
```
|
||||
Variables.Scene(scene)
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
Variables.Scene(gameObjectInScene)
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
Variables.ActiveScene
|
||||
```
|
||||
|
||||
### Application
|
||||
|
||||
To access application variables:
|
||||
|
||||
```
|
||||
Variables.Application
|
||||
```
|
||||
|
||||
### Saved
|
||||
|
||||
To access saved variables:
|
||||
|
||||
```
|
||||
Variables.Saved
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Operations
|
||||
|
||||
In these examples, the lowercase scope refers to one of the previous scopes.
|
||||
|
||||
### Get
|
||||
|
||||
To get the value of a variable, use the Get method with a name parameter:
|
||||
|
||||
```
|
||||
scope.Get("name");
|
||||
```
|
||||
|
||||
Note that variables are not strongly typed; they need to be cast manually. For example:
|
||||
|
||||
```
|
||||
int health = (int)Variables.Object(player).Get("health")
|
||||
```
|
||||
|
||||
### Set
|
||||
|
||||
To set the value of a variable, use the Set method with the name and value parameters:
|
||||
|
||||
```
|
||||
scope.Set("name", value);
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
Variables.Object(player).Set("health", 100);
|
||||
```
|
||||
|
||||
Because variables are not strongly typed, pass any value to the second parameter, even if the variable currently is of a different type.
|
||||
|
||||
> [!NOTE]
|
||||
> Using the set method with a variable name that does not yet exist defines a new variable.
|
||||
|
||||
### Is Defined
|
||||
|
||||
To check if a variable is defined, use the IsDefined method with a name parameter:
|
||||
|
||||
```
|
||||
scope.IsDefined("name");
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
if (Variables.Application.IsDefined("score"))
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
@ -0,0 +1,70 @@
|
||||
# Variables
|
||||
|
||||
Variables act as a container for a piece of information that might change as an application runs. To define a variable, you need to provide:
|
||||
|
||||
- A name for the variable, such as `MyVariable`.
|
||||
- The type of data the variable holds, such as `int` or `string` .
|
||||
- A value for the variable, such as `1` or `cat`.
|
||||
|
||||
In Visual Scripting, you can give a node the name of a variable, instead of a fixed value or text. Your Script Graph uses the variable's name to access its value. For example, you can use a variable called `Count`, with an `int` type and a value of `1`. You can use an Add node in Visual Scripting to add 1 to the value of `Count`, and save the new value in `Count` to use again in another part of your Script Graph, or a different Script Graph.
|
||||
|
||||
Variables also have scopes. A variable's scope determines what parts of your Script Graph can access which variables to read or modify their values. The scope can also decide whether another Script Graph can access a variable.
|
||||
|
||||
You can create and manage variables in a graph from the Blackboard. For more information on the Blackboard, see [The Blackboard](vs-interface-overview.md#the-blackboard). For more information on how to use variables, see [Create and add a variable to a Script Graph](vs-add-variable-graph.md).
|
||||
|
||||
## Variable scopes
|
||||
|
||||
Each variable scope has its own tab on the Blackboard, except Flow variables. Visual Scripting has six variable scopes.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><strong>Variable Scope</strong></th>
|
||||
<th><strong>Property</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Flow Variables</strong></td>
|
||||
<td>Flow variables are like local variables in a scripting language: they have the smallest scope. You can't use a Flow variable if:<br/>
|
||||
<ul>
|
||||
<li>The Flow variable doesn’t have a direct or indirect connection to the nodes where you want to use its value. The node where the variable is defined must be a part of the logical flow where you want to use its value.</li>
|
||||
<li>The Flow variable hasn’t been set before Visual Scripting tries to run any logic that needs its value. The node where the variable is defined must come before any other logic in your graph.</li>
|
||||
</ul>
|
||||
You can't create a Flow variable from the Blackboard - you can create one with a Set Variable node and set the <strong>Scope</strong> to <strong>Flow</strong>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Graph Variables</strong></td>
|
||||
<td>Graph variables belong to a specific Script Graph. You can't access or modify Graph variables outside the specific Script Graph where they're defined. <br/>You also can't create a new Graph variable unless you have a Script Graph open in the Graph window.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Object Variables</strong></td>
|
||||
<td>Object variables belong to a specific GameObject. You can edit an Object variable from the Unity Editor's Inspector for the GameObject, and the Object variable is accessible in all graphs attached to the GameObject. <br/>You can't create a new Object variable unless you've opened your Script Graph from a Script Machine component on a GameObject.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Scene Variables</strong></td>
|
||||
<td>Scene variables belong to the current scene. Visual Scripting creates a new GameObject in your scene to hold references to your Scene variables. You can access your Scene variables from any Script Graph attached to a different GameObject in a single scene, but can't access a Scene variable in another scene in your project.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>App or Application Variables</strong></td>
|
||||
<td>Application variables belong to your entire application. You can access an Application variable across multiple scenes while your application runs, and the Application variable would hold your changes. <br/>Any values held in an Application variable reset to their default values after your application quits.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Saved Variables</strong></td>
|
||||
<td>Saved variables are like Application variables, but they persist even after your application quits. You can use a Saved variable as a simple but powerful save system. Unity stores Saved variables in its <code>PlayerPrefs</code>, and they don't refer to Unity objects, like GameObjects and components. For more information on <code>PlayerPrefs</code>, see <a href="https://docs.unity3d.com/ScriptReference/PlayerPrefs.html">PlayerPrefs</a> in the Unity User Manual Scripting Reference.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
> [!NOTE]
|
||||
> You can still access the Blackboard and create new variables with a State Graph open in the Graph window, but you can't add a variable node and use it inside a State Graph.
|
||||
|
||||
For Saved variables, there are two additional tabs on the Blackboard: **Initial** and **Saved**:
|
||||
|
||||
- Values defined in the **Initial** tab apply to all new instances of your application as default values.
|
||||
|
||||
- Values defined in the **Saved** tab are the last modified values for those variables, based on when you last ran your application. You can edit them manually, or delete the values to reset them to the values defined in the **Initial** tab.
|
||||
|
||||

|
||||
|
@ -0,0 +1,118 @@
|
||||
# Version control systems
|
||||
|
||||
To avoid any problems with automatically generated files, exclude some Visual Scripting files from your version control solution.
|
||||
|
||||
To exclude files from version control, include a file or configure your settings to specify which files and folders to exclude:
|
||||
|
||||
1. Create a new file at the root of your project directory.
|
||||
|
||||
>[!TIP]
|
||||
> The root of your project directory is at the level above your **Assets** folder.
|
||||
|
||||
2. Name the file based on your chosen version control system:
|
||||
|
||||
- **Git**: `.gitignore`. For more information, see [Git's documentation on gitignore](https://git-scm.com/docs/gitignore).
|
||||
|
||||
- **Unity Collab**: `.collabignore`. For more information, see the [Unity User Manual](https://docs.unity3d.com/Manual/UnityCollaborateIgnoreFiles.html).
|
||||
|
||||
- **Subversion**: Ignore the files from your `svn:ignore` property or runtime configuration options. For more information, see Subversion's documentation on [Ignoring Unversioned Items](https://svnbook.red-bean.com/en/1.7/svn.advanced.props.special.ignore.html).
|
||||
|
||||
3. Open the file in a text editor.
|
||||
|
||||
4. Add the appropriate files or file patterns to your ignore file or configuration. For an example and more information, see [Ignore file template](#ignore-file-template).
|
||||
|
||||
> [!NOTE]
|
||||
> If you have an issue when you try to create a `.gitignore` file on Windows, refer to Microsoft's documentation on [how to create a .gitignore file from the command line](https://docs.microsoft.com/en-us/azure/devops/repos/git/ignore-files?view=azure-devops&tabs=command-line#create-a-gitignore).
|
||||
|
||||
## Ignore file template
|
||||
|
||||
The following template ignores all core Visual Scripting files, but preserves your project settings and variables. It also includes the standard Unity ignore directives for files that you can exclude from version control. For more information, see the `Unity.gitignore` file included in [GitHub's gitignore template repository](https://github.com/github/gitignore/blob/master/Unity.gitignore).
|
||||
|
||||
Refer to the comments in the template for which lines to comment or remove.
|
||||
|
||||
```
|
||||
# Optionally exclude these transient (generated) files,
|
||||
# because they can be easily re-generated by the package
|
||||
|
||||
Assets/Unity.VisualScripting.Generated/VisualScripting.Flow/UnitOptions.db
|
||||
Assets/Unity.VisualScripting.Generated/VisualScripting.Flow/UnitOptions.db.meta
|
||||
Assets/Unity.VisualScripting.Generated/VisualScripting.Core/Property Providers
|
||||
Assets/Unity.VisualScripting.Generated/VisualScripting.Core/Property Providers.meta
|
||||
|
||||
## Unity
|
||||
# From: https://github.com/github/gitignore/blob/master/Unity.gitignore
|
||||
|
||||
/[Ll]ibrary/
|
||||
/[Tt]emp/
|
||||
/[Oo]bj/
|
||||
/[Bb]uild/
|
||||
/[Bb]uilds/
|
||||
/[Ll]ogs/
|
||||
/[Uu]ser[Ss]ettings/
|
||||
|
||||
# MemoryCaptures can get excessive in size.
|
||||
# They also could contain extremely sensitive data
|
||||
/[Mm]emoryCaptures/
|
||||
|
||||
# Asset meta data should only be ignored when the corresponding asset is also ignored
|
||||
!/[Aa]ssets/**/*.meta
|
||||
|
||||
# Uncomment this line if you want to ignore the asset store tools plugin
|
||||
# /[Aa]ssets/AssetStoreTools*
|
||||
|
||||
# Autogenerated Jetbrains Rider plugin
|
||||
/[Aa]ssets/Plugins/Editor/JetBrains*
|
||||
|
||||
# Visual Studio cache directory
|
||||
.vs/
|
||||
|
||||
# Gradle cache directory
|
||||
.gradle/
|
||||
|
||||
# Autogenerated VS/MD/Consulo solution and project files
|
||||
ExportedObj/
|
||||
.consulo/
|
||||
*.csproj
|
||||
*.unityproj
|
||||
*.sln
|
||||
*.suo
|
||||
*.tmp
|
||||
*.user
|
||||
*.userprefs
|
||||
*.pidb
|
||||
*.booproj
|
||||
*.svd
|
||||
*.pdb
|
||||
*.opendb
|
||||
*.VC.db
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
*.pdb.meta
|
||||
*.mdb.meta
|
||||
|
||||
# Unity3D Generated File On Crash Reports
|
||||
sysinfo.txt
|
||||
|
||||
# Builds
|
||||
*.apk
|
||||
*.aab
|
||||
*.unitypackage
|
||||
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
# Packed Addressables
|
||||
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*.*.bin*
|
||||
|
||||
# Temporary auto-generated Android Assets
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa.meta
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa/*
|
||||
|
||||
```
|
||||
|
||||
## Remove previously committed files
|
||||
If you committed any files to a version control solution that you want to exclude:
|
||||
|
||||
- See Git's documentation on [the `git-rm` command](https://git-scm.com/docs/git-rm).
|
||||
- See Subversion's documentation on [the `svn delete` command](https://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.delete.html).
|