GameVsJam/3d Prototyp/Library/PackageCache/com.unity.visualscripting@1.../Documentation~/vs-nodes-events-on-mouse-up...

4.3 KiB

On Mouse Up As Button node

[!NOTE] The On Mouse Up As Button [!includenodes-note-manual]

The On Mouse Up As Button node listens for a user to release their mouse button after they click a Collider in your application. [!includenodes-desc-end]

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

An image of the Graph window. An On Mouse Up As Button node displays with its details in the Graph Inspector.

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 [!includenodes-single-input]

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 [!includenodes-additional-settings]

[!include[nodes-coroutine](./snippets/nodes-coroutine.md)]
Name Type Description

Outputs

The On Mouse Up As Button [!includenodes-single-output]

[!include[nodes-input-output-trigger](./snippets/input-manager/nodes-input-output-trigger.md)]
Name Type Description

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.

An image of the Graph window. An On Mouse Up As Button node has its Target set to This and is set to run as a coroutine. Its Trigger output port connects to the Invoke input port on a Scene Manager Load Scene node. The Load Scene node loads the scene from Scene Build Index 1, with an inline value. Its Exit output port connects to the Enter input port on a Wait Until node. The Wait Until node waits until a Scene Is Loaded node returns True as its Condition input. When Is Loaded returns True, the Wait Until node's Exit output port triggers the Invoke input port on a Scene Manager Get Scene At node. The Get Scene At node gets the scene from Index 1 with an inline value. Its Exit output port connects to the Invoke input port on a Scene Manager Set Active Scene node. The Set Active Scene node takes the Result scene output from the Get Scene At node and changes the active scene in the application.

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

An image of the Game view, that displays a simple plane with three red spheres.

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

An image of the Game view, that displays a simple plane with a single red cube.

[!includenodes-related] On Mouse Up As Button node: