Files
.vs
Assets
Library
APIUpdater
Artifacts
Bee
BuildPlayerData
PackageCache
com.unity.collab-proxy@2.5.2
com.unity.editorcoroutines@1.0.0
com.unity.ext.nunit@1.0.6
com.unity.feature.development@1.0.1
com.unity.ide.rider@3.0.31
com.unity.ide.visualstudio@2.0.22
com.unity.ide.vscode@1.2.5
com.unity.modules.ai@1.0.0
com.unity.modules.androidjni@1.0.0
com.unity.modules.animation@1.0.0
com.unity.modules.assetbundle@1.0.0
com.unity.modules.audio@1.0.0
com.unity.modules.cloth@1.0.0
com.unity.modules.director@1.0.0
com.unity.modules.imageconversion@1.0.0
com.unity.modules.imgui@1.0.0
com.unity.modules.jsonserialize@1.0.0
com.unity.modules.particlesystem@1.0.0
com.unity.modules.physics2d@1.0.0
com.unity.modules.physics@1.0.0
com.unity.modules.screencapture@1.0.0
com.unity.modules.subsystems@1.0.0
com.unity.modules.terrain@1.0.0
com.unity.modules.terrainphysics@1.0.0
com.unity.modules.tilemap@1.0.0
com.unity.modules.ui@1.0.0
com.unity.modules.uielements@1.0.0
com.unity.modules.umbra@1.0.0
com.unity.modules.unityanalytics@1.0.0
com.unity.modules.unitywebrequest@1.0.0
com.unity.modules.unitywebrequestassetbundle@1.0.0
com.unity.modules.unitywebrequestaudio@1.0.0
com.unity.modules.unitywebrequesttexture@1.0.0
com.unity.modules.unitywebrequestwww@1.0.0
com.unity.modules.vehicles@1.0.0
com.unity.modules.video@1.0.0
com.unity.modules.vr@1.0.0
com.unity.modules.wind@1.0.0
com.unity.modules.xr@1.0.0
com.unity.performance.profile-analyzer@1.2.2
com.unity.settings-manager@2.0.1
com.unity.test-framework@1.1.33
com.unity.testtools.codecoverage@1.2.6
com.unity.textmeshpro@3.0.6
com.unity.timeline@1.7.6
com.unity.ugui@1.0.0
com.unity.visualscripting@1.9.4
Documentation~
images
snippets
TableOfContents.md
index.md
vs-add-custom-event-node-trigger.md
vs-add-custom-event-node.md
vs-add-inspectable-attribute-custom-types.md
vs-add-node-to-graph.md
vs-add-remove-node-library.md
vs-add-remove-type-options.md
vs-add-subgraph.md
vs-add-triggers-data-graph.md
vs-add-variable-graph.md
vs-advanced-topics-intro.md
vs-aot.md
vs-attach-graph-machine.md
vs-basic-concepts.md
vs-capture-player-input-add-component.md
vs-capture-player-input.md
vs-capturing-player-inputs-new.md
vs-capturing-player-inputs-old.md
vs-configuration.md
vs-control-schemes.md
vs-control.md
vs-create-custom-drawer.md
vs-create-custom-node-add-docs.md
vs-create-custom-node-add-logic.md
vs-create-custom-node-add-ports.md
vs-create-custom-node-add-relations.md
vs-create-custom-node-attributes-reference.md
vs-create-custom-node-empty.md
vs-create-custom-node.md
vs-create-graph-assign-existing-gameobject.md
vs-create-graph-assign-new-gameobject.md
vs-create-graph-on-machine.md
vs-create-graph-project-window.md
vs-create-graph-unassigned-flow.md
vs-create-graph.md
vs-create-own-custom-event-listen-code.md
vs-create-own-custom-event-node-trigger-code.md
vs-create-own-custom-event-node.md
vs-create-own-custom-event-send-node.md
vs-create-restore-backups.md
vs-create-state.md
vs-creating-connections.md
vs-creating-transition.md
vs-custom-events.md
vs-custom-types.md
vs-debug-messages.md
vs-debugging.md
vs-developers-guide.md
vs-editor-script-issues.md
vs-events-reference.md
vs-events.md
vs-formula.md
vs-graph-machine-types.md
vs-graph-types.md
vs-groups.md
vs-input-nodes.md
vs-interface-overview.md
vs-live-edit-runtime.md
vs-live.md
vs-nesting-add-state-unit.md
vs-nesting-add-subgraph.md
vs-nesting-add-triggers-data-graph.md
vs-nesting-input-node.md
vs-nesting-nodes.md
vs-nesting-output-node.md
vs-nesting-state-unit-node.md
vs-nesting-subgraph-node.md
vs-nesting-subgraphs-state-units.md
vs-nodes-events-input-system-button.md
vs-nodes-events-input-system-float.md
vs-nodes-events-input-system-vector2.md
vs-nodes-events-on-button-input.md
vs-nodes-events-on-keyboard-input.md
vs-nodes-events-on-mouse-down.md
vs-nodes-events-on-mouse-drag.md
vs-nodes-events-on-mouse-enter.md
vs-nodes-events-on-mouse-exit.md
vs-nodes-events-on-mouse-input.md
vs-nodes-events-on-mouse-over.md
vs-nodes-events-on-mouse-up-button.md
vs-nodes-events-on-mouse-up.md
vs-nodes-reference.md
vs-nodes.md
vs-nulls.md
vs-open-graph-edit.md
vs-refactor-add-attribute.md
vs-refactoring.md
vs-relations.md
vs-script-graphs-intro.md
vs-scripts-reference.md
vs-self.md
vs-set-preferences.md
vs-state-graphs-intro.md
vs-states-reference.md
vs-sticky-notes.md
vs-time.md
vs-transitions.md
vs-types.md
vs-update.md
vs-using-custom-types.md
vs-variables-api.md
vs-variables-reference.md
vs-variables.md
vs-version-control.md
Editor
Graphics
Runtime
.npmignore.release
.signature
CHANGELOG.md
CHANGELOG.md.meta
Editor.meta
Graphics.meta
LICENSE.md
LICENSE.md.meta
README.md
README.md.meta
Runtime.meta
Third Party Notices.md
Third Party Notices.md.meta
ValidationConfig.json
ValidationConfig.json.meta
ValidationExceptions.json
ValidationExceptions.json.meta
package.json
package.json.meta
PackageManager
PlayModeViewStates
PlayerDataCache
ScriptAssemblies
Search
ShaderCache
SplashScreenCache
StateCache
UIElements
AnnotationManager
ArtifactDB
ArtifactDB-lock
BuildPlayer.prefs
BuildSettings.asset
EditorOnlyScriptingSettings.json
EditorOnlyVirtualTextureState.json
EditorSnapSettings.asset
EditorUserBuildSettings.asset
InspectorExpandedItems.asset
LastBuild.buildreport
LastSceneManagerSetup.txt
LibraryFormatVersion.txt
MonoManager.asset
SceneVisibilityState.asset
ScriptMapper
ShaderCache.db
SourceAssetDB
SourceAssetDB-lock
SpriteAtlasDatabase.asset
Style.catalog
expandedItems
ilpp.pid
Logs
Packages
ProjectSettings
UserSettings
obj
.vsconfig
Assembly-CSharp.Player.csproj
Assembly-CSharp.csproj
TM1.sln
Unity.CollabProxy.Editor.csproj
Unity.EditorCoroutines.Editor.csproj
Unity.Performance.Profile-Analyzer.Editor.csproj
Unity.PlasticSCM.Editor.csproj
Unity.Rider.Editor.csproj
Unity.Settings.Editor.csproj
Unity.TestTools.CodeCoverage.Editor.OpenCover.Model.csproj
Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection.csproj
Unity.TestTools.CodeCoverage.Editor.csproj
Unity.TextMeshPro.Editor.csproj
Unity.TextMeshPro.Player.csproj
Unity.TextMeshPro.csproj
Unity.Timeline.Editor.csproj
Unity.Timeline.Player.csproj
Unity.Timeline.csproj
Unity.VSCode.Editor.csproj
Unity.VisualScripting.Core.Editor.csproj
Unity.VisualScripting.Core.Player.csproj
Unity.VisualScripting.Core.csproj
Unity.VisualScripting.Flow.Editor.csproj
Unity.VisualScripting.Flow.Player.csproj
Unity.VisualScripting.Flow.csproj
Unity.VisualScripting.SettingsProvider.Editor.csproj
Unity.VisualScripting.Shared.Editor.csproj
Unity.VisualScripting.State.Editor.csproj
Unity.VisualScripting.State.Player.csproj
Unity.VisualScripting.State.csproj
Unity.VisualStudio.Editor.csproj
UnityEditor.TestRunner.csproj
UnityEditor.UI.csproj
UnityEngine.TestRunner.Player.csproj
UnityEngine.TestRunner.csproj
UnityEngine.UI.Player.csproj
UnityEngine.UI.csproj
TP_Multimedia/Library/PackageCache/com.unity.visualscripting@1.9.4/Documentation~/vs-add-custom-event-node.md

48 lines
2.6 KiB
Markdown
Raw Normal View History

2025-01-17 13:10:20 +01:00
# 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.
![An image of the Graph window, that displays a Custom Event node. Its Arguments are set to 1, its Target is set to This, and its Name is set to On Damage.](images/vs-events-custom-event-node.png)
## 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).