Skip to main content

Trigger Script Nodes

Trigger Script Node
Trigger Script Node

Trigger script nodes allow script functions (methods) to be triggered during dialogue playback.

note

This node can only be used with MonoBehaviour types or static class methods.

Dragging a C# Script onto a Trigger Script Node.
Dragging a Script onto a Trigger Script Node

You can drag-and-drop a C# file onto the 'Class Name' field, or type the fully qualified class name (including namespace) yourself for the class you want to use.

Once you have provided a valid class, you can choose the method you want to call from the method dropdown.

If no method dropdown is provided, it means that the trigger script node couldn't find any valid methods. You can still manually type a method definition in the method field (see Method Definitions).

After you set or write a method defintion, the parameters for the node will be updated to match the method.

tip

Trigger Script Nodes can only use int, float, bool, and string parameter types. It also supports object type parameters, but if you use a method which takes in an object type, that method needs to be able to handle the conversion of the string/int/float/bool value passed in, since EasyTalk cannot handle complex object types at this time.

You can either manually enter values into the parameter fields, or you can pass them in from the outputs of other nodes.

Make sure you set the 'Apply To' dropdown to the correct setting. Each option is described below:

  • SELF - Use this when the triggered MonoBahaviour class component is on the same GameObject as the Dialogue Controller and you want to call the method on that GameObject.
  • ALL - Used when you want to call the method on all instances of the MonoBehaviour class specified.
  • FIRST - Finds the first instance of the specified MonoBehaviour class in the scene, using GameObject.Find and calls the method on that object.
  • TAG - Finds the GameObject with the specified tag name and MonoBehaviour component, then calls the method on it.
  • NAME - Finds the GameObject with the specified name and MonoBehaviour component, then calls the method on it.
  • STATIC - Calls the static class method.

The method is executed each time it is encountered during dialogue flow or node evaluations. The return value of the method, if there is one, will be sent to the value output of the trigger script node.

Each trigger script node contains a dialogue flow input, a dialogue flow output, a value input for each method parameter, and if there is a return value for the method being called, a value output.

Example 1: Mathf

Calling UnityEngine.Mathf functions from a Trigger Script Node.
An example of using the Trigger Script Node to perform math functions in a Dialogue using UnityEngine.Mathf

In the above setup, the Trigger Script Node will call the Lerp method of the Mathf class, passing in 0.0 for the first parameter, 5.0 for the second parameter, and the value of the 'progress' variable for the third variable.

The result of the Lerp goes to the value output, and can be sent to other nodes for further processing. In this example, we're just setting the value of another float variable via a Set Variable Node.

note

Take notice of how the 'Apply To' setting is set to 'STATIC', since the Lerp method is a static class method of Mathf.

Method Definitions

Method descriptions in the method field are in the following format:

METHOD_NAME(TYPE_1,TYPE_2,TYPE_3,TYPE_4):RETURN_TYPE

The supported types are int, float, bool, string, and object.

Example 1

Description of a method called AddNumbers which takes in two float parameters and returns a float value:

AddNumbers(float,float):float

Example 2

Description of a method called SetText which takes in a string and returns a boolean value.

SetText(string):bool
note

Trigger script nodes support a maximum of 4 parameters.