UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

Unigine Script

To use functions listed on this page include the unigine.h script into your project (it can be found in the data/core directory). All the functions of this script are safe.

The unigine.h script also defines math constants, color codes and data types (for single or double precision coordinates).

void swap (variable v0, variable v1)

Interchanges values of two variables.

Arguments

  • variable v0 - The first variable.
  • variable v1 - The second variable.

void sleep (float time)

Causes the currently executing thread to sleep (cease execution) for the specified number of seconds. The sleep() function is thread-safe: when you set to sleep multiple threads, there are no side effects such as thread interferences appears.

Arguments

  • float time - Time of thread sleeping in seconds.

Node node_cast (Node node)

Converts a base node to its derived type.

Arguments

  • Node node - Node to be type-casted.

Return value

Type-casted node.

Node node_clone (Node node)

Clones a node and its children and then converts the node to its derived type. It is used for correct cloning of nodes that have assigned bodies and joints.

Arguments

  • Node node - Node to be cloned.

Return value

Type-casted copy of the node.

Node node_append (Node node)

Establishes script ownership over the node and its children. It also casts nodes to their types. Do not forget, the a node can have only one owner.

Arguments

  • Node node - Node to be appended.

Return value

Appended node.

Node node_remove (Node node)

Releases script ownership over the node and its children. It also casts nodes to their types. Do not forget, that an orphan node need to be assigned to another owner.

Arguments

  • Node node - Node to be released.

Return value

Released node.

void node_delete (Node node)

Deletes a node and its children.

Arguments

  • Node node - Node to be deleted.

Node node_load (string name)

Loads a node from a file and establishes script ownership over it and its children. It also casts nodes to their types. If a node cannot be found, it will lead to the crash.

Arguments

  • string name - Node file to be loaded.

Return value

Loaded node.

int node_save (string name, Node node)

Saves a node into a .node file.

Arguments

  • string name - File to save the node into.
  • Node node - Node to be saved.

Return value

1, if the node is saved successfully; otherwise, 0.

Node node_editor (string name)

Gets an Engine Editor node by the name and casts it to its type.

Arguments

  • string name - Node name.

Return value

Type-casted node.

Body body_cast (Body body)

Converts a base body to its derived type.

Arguments

  • Body body - Body to be type-casted.

Return value

Type-casted body.

Body body_clone (Body body, Object object = NULL)

Clones the body and then converts it to its derived type. It also assigns a copy to a given object if necessary. This function correctly clones joints of the body.

Arguments

  • Body body - Body to be cloned.
  • Object object = NULL - Object, to which the copied body will be assigned. This is an optional argument.

Return value

Type-casted copy of the body.

Shape shape_cast (Shape shape)

Converts a base shape to its derived type.

Arguments

  • Shape shape - Shape to be type-casted.

Return value

Type-casted shape.

Shape shape_clone (Shape shape)

Clones the shape and then converts it to its derived type. This function correctly clones joints of the shape.

Arguments

  • Shape shape - Shape to be cloned.

Return value

Type-casted copy of the shape.

Joint joint_cast (Joint joint)

Converts a base joint to its derived type.

Arguments

  • Joint joint - Joint to be type-casted.

Return value

Type-casted joint.

Joint joint_clone (Joint joint)

Clones the joint and then converts it to its derived type. This function correctly clones the joints.

Arguments

  • Joint joint - Joint to be cloned.

Return value

Type-casted copy of the joint.

Widget widget_cast (Widget widget)

Converts a base widget to its derived type.

Arguments

  • Widget widget - Widget to be type-casted.

Return value

Type-casted widget.

void body_traversal (Body body, string name)

Calls a specified function for a given body and its children.

Arguments

  • Body body - Body to be passed to a function.
  • string name - Function to be called.

void body_shape_traversal (Body body, string name)

Calls a specified function for shapes of a given body and body's children.

Arguments

  • Body body - Body, the shapes of which will be passed to a function.
  • string name - Function to be called.

void body_joint_traversal (Body body, string name)

Calls a specified function for joints of a given body and body's children.

Arguments

  • Body body - Body, the joints of which will be passed to a function.
  • string name - Function to be called.

void node_traversal (Node node, string name)

Calls a specified function for a given node and its children.

Arguments

  • Node node - Node to be passed to a function.
  • string name - Function to be called.

void node_body_traversal (Node node, string name)

Calls a specified function for bodies of a given node and its children.

Arguments

  • Node node - Node, the body of which will be passed to a function.
  • string name - Function to be called.

void node_shape_traversal (Node node, string name)

Calls a specified function for shapes of a given node and its children.

Arguments

  • Node node - Node, the shapes of which will be passed to a function.
  • string name - Function to be called.

void node_joint_traversal (Node node, string name)

Calls a specified function for joints of a given node and its children.

Arguments

  • Node node - Node, the joints of which will be passed to a function.
  • string name - Function to be called.
Last update: 2017-07-03