Implementing Node
Behavior

After you have defined the topology for the node, you can focus on implementing the
behavior for the node.

Adding Slots

In addition to using AZ Code Generator to set up the node's topology, it is also
possible to manually add execution and/or data slots if preferred. The following example
from the IsNull logic node adds a Reference input
slot for data reference and an Is Null output slot. The output slot
returns a Boolean value depending on the evaluation of the data that was input. The
source
code is in the location
\dev\Gems\ScriptCanvas\Code\Include\ScriptCanvas\Libraries\Logic\IsNull.cpp.

When the node is initialized, the added slots appear in the Script Canvas
editor.

Receiving Input
Signals

Nodes can receive input signals when a node's execution slot is triggered. To detect
which signal has been triggered, implement OnInputSignal, as in the following
example.

Copy

void OnInputSignal(const SlotId&) override;

To get the ID of the input signal, AZ Code Generator provides some convenient helper
functions in a namespace that corresponds to the generated node. These helper functions
make
it easier to access the node's properties and slot IDs.

As an example, in the Delay node two input slots can be signaled:
In and Reset.

In the following code, the Delay node's In and
Reset slots use the generated helper functions
CountdownProperty::GetInSlotId(this); and
CountdownProperty::GetResetSlotId(this); to get their IDs. The source code is
from
dev\Gems\ScriptCanvas\Code\Include\ScriptCanvas\Libraries\Time\Countdown.cpp.

If your node is connected to one or more buses during its lifetime, ensure that it
disconnects from those buses before it exits. Otherwise, your node might be handling
events that it no longer should.

Querying Inbound
Data

The Delay node example has the inbound data slots
Time, Loop, and
Hold.

Script Canvas properties that specify the ScriptCanvas_Property::Input
attribute can be queried by the node to do necessary processing. To do this, use the
code-generated convenience helpers
CountdownProperty::Get{PropertyName}(this);. The
following source code is in
dev\Gems\ScriptCanvas\Code\Include\ScriptCanvas\Libraries\Time\Countdown.cpp.