TriggerCustomEvent

Method

Trigger a custom visual scripting event.

Definition

public static void TriggerCustomEvent(GameObject target, string message, params object[] args)
public static void TriggerCustomEvent(GameObject target, string message, params object[] args)

Parameters

ParameterDescription
GameObject target

The target gameobject we want to trigger the event on. All script machines on this gameobject will receive the event.

string message

The name of the event.

object[] args

The args for the event.

Examples

When called, all ScriptMachines on the target gameobject will trigger the custom events that have the matching event name.

public GameObject objectWithScriptMachine;

public void RaiseVisualScriptingEvent()
{
VisualScriptingUtility.TriggerCustomEvent(objectWithScriptMachine, "MyEvent");
}

public void RaiseVisualScriptingEventWithParameters(int param1, int param2)
{
VisualScriptingUtility.TriggerCustomEvent(objectWithScriptMachine, "MyEventWithParams", param1, param2);
}
public GameObject objectWithScriptMachine;

public void RaiseVisualScriptingEvent()
{
VisualScriptingUtility.TriggerCustomEvent(objectWithScriptMachine, "MyEvent");
}

public void RaiseVisualScriptingEventWithParameters(int param1, int param2)
{
VisualScriptingUtility.TriggerCustomEvent(objectWithScriptMachine, "MyEventWithParams", param1, param2);
}