Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins

NodeTrigger Class

A trigger node is a zero-sized node that has no visual representation and fires callbacks when:

  • It is enabled/disabled (the enabled callback function is called)
  • Its transformation is changed (the position callback function is called)
The trigger node is usually added as a child node to another node, so that the callbacks will be fired on the parent node enabling/disabling or transforming.
Notice
The enabled and position callback functions should be implemented in the world script.

For example, to detect if some node has been enabled (for example, a world clutter node that renders nodes only around the camera has enabled it), the trigger node is added as a child to this node and fires a corresponding callback.

NodeTrigger Class

This class inherits from Node

Members


NodeTrigger ()

Constructor. Creates a new trigger node.

string getEnabledCallbackName ()

Returns the name of callback function to be fired on enabling the trigger node. This callback function is set via setEnabledCallbackName().

Return value

Name of the callback function.

string getPositionCallbackName ()

Returns the name of callback function to be fired on changing the trigger node position. This callback function is set via setPositionCallbackName().

Return value

Name of the callback function.

void setEnabledCallbackName (string name)

Sets a callback function to be fired when the trigger node is enabled. The callback function should accept a NodeTrigger that fired the callback as its first argument. However, it can also receive no arguments.

Arguments

  • string name - Name of the callback function.

Examples

Source code (UnigineScript)
NodeTrigger trigger;

// Implement a callback function
int enabled_callback_func() {
	// Your callback code
	return 1;
}

// Set the callback to fire when NodeTrigger is enabled
trigger.setEnabledCallbackName("enabled_callback_func");

void setEnabledCallback (variable function, variable arg0 = 0, variable arg1 = 0)

Sets a callback function to be fired when the trigger node is enabled. The callback function should accept a NodeTrigger that fired the callback as its first argument. In addition, it can also take any other two arguments. However, it can also receive no arguments.

Arguments

  • variable function - Name of the callback function.
  • variable arg0 - Argument to the function. This is an optional parameter.
  • variable arg1 - Argument to the function. This is an optional parameter.

Examples

Source code (UnigineScript)
NodeTrigger trigger;
MyClass arg0; // it can be an argument of any type

// Implement a callback function
// It can also take any other 2 arguments, if necessary
int enabled_callback_func(NodeTrigger trigger, MyClass arg0) {
	// Your callback code
	return 1;
}

// Set the callback to fire when NodeTrigger is enabled
trigger.setEnabledCallback("enabled_callback_func", arg0);

void setPositionCallbackName (string name)

Sets a callback function to be fired when the trigger node position has changed. The callback function should accept a NodeTrigger that fired the callback as its first argument. However, it can also receive no arguments.

Arguments

  • string name - Name of the callback function.

Examples

Source code (UnigineScript)
NodeTrigger trigger;

// Implement a callback function
int repositioned_callback_func() {
	// Your callback code
	return 1;
}

// Set the callback to fire when NodeTrigger has changed its position
trigger.setPositionCallbackName("repositioned_callback_func");

void setPositionCallback (variable function, variable arg0 = 0, variable arg1 = 0)

Sets a callback function to be fired when the trigger node position has changed. The callback function should accept a NodeTrigger that fired the callback as its first argument. In addition, it can also take any other two arguments. However, it can also receive no arguments.

Arguments

  • variable function - Name of the callback function.
  • variable arg0 - Argument to the function. This is an optional parameter.
  • variable arg1 - Argument to the function. This is an optional parameter.

Examples

Source code (UnigineScript)
NodeTrigger trigger;
MyClass arg0; // it can be an argument of any type

// Implement a callback function
// It can also take any other 2 arguments, if necessary
int repositioned_callback_func(NodeTrigger trigger, MyClass arg0) {
	// Your callback code
	return 1;
}

// Set the callback to fire when NodeTrigger has changed its position
trigger.setPositionCallback("repositioned_callback_func", arg0);
Last update: 2017-07-03