This page has been translated automatically.
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
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

engine.editor Functions

This set of functions is related to the Unigine Engine Editor that loads and manages the hierarchy of nodes displayed in the editor.

See Also

int engine.editor.addNode (Node node, int is_runtime_node = 0)

Appends a given node to UnigineEditor.
Notice
The node can have only one owner, so before appending it to the Unigine Editor, its ownership by a script must be removed. Otherwise, it can result in a double deletion at the same address and engine crash.

Arguments

  • Node node - Node to append.
  • int is_runtime_node - A value indicating if the node should be deleted on quitting the world: 1 to delete the node; 0 to save the node.

Return value

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

variable engine.editor.call (variable function)

Executes a function of Unigine Editor from an external script. The function should not take any arguments.

Arguments

  • variable function - Name of the function to execute.

Return value

Value returned by the function.

variable engine.editor.call (variable function, variable arg)

Executes a function of Unigine Editor from an external script. The function should take one argument.

Arguments

  • variable function - Name of the function to execute.
  • variable arg - Argument of the function.

Return value

Value returned by the function.

variable engine.editor.call (variable function, variable arg0, variable arg1)

Executes a function of Unigine Editor from an external script. The function should take two arguments.

Arguments

  • variable function - Name of the function to execute.
  • variable arg0 - Argument of the function.
  • variable arg1 - Argument of the function.

Return value

Value returned by the function.

variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2)

Executes a function of Unigine Editor from an external script. The function should take three arguments.

Arguments

  • variable function - Name of the function to execute.
  • variable arg0 - Argument of the function.
  • variable arg1 - Argument of the function.
  • variable arg2 - Argument of the function.

Return value

Value returned by the function.

variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2, variable arg3)

Executes a function of Unigine Editor from an external script. The function should take four arguments.

Arguments

  • variable function - Name of the function to execute.
  • variable arg0 - Argument of the function.
  • variable arg1 - Argument of the function.
  • variable arg2 - Argument of the function.
  • variable arg3 - Argument of the function.

Return value

Value returned by the function.

variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2, variable arg3, variable arg4)

Executes a function of Unigine Editor from an external script. The function should take five arguments.

Arguments

  • variable function - Name of the function to execute.
  • variable arg0 - Argument of the function.
  • variable arg1 - Argument of the function.
  • variable arg2 - Argument of the function.
  • variable arg3 - Argument of the function.
  • variable arg4 - Argument of the function.

Return value

Value returned by the function.

variable engine.editor.call (variable function, variable arg0, variable arg1, variable arg2, variable arg3, variable arg3, variable arg6)

Executes a function of Unigine Editor from an external script. The function should take six arguments.

Arguments

  • variable function - Name of the function to execute.
  • variable arg0 - Argument of the function.
  • variable arg1 - Argument of the function.
  • variable arg2 - Argument of the function.
  • variable arg3 - Argument of the function.
  • variable arg3 - Argument of the function.
  • variable arg6 - Argument of the function.

Return value

Value returned by the function.

variable engine.editor.callv (variable function, int id = [])

Executes a function of the editor from an external script. The function takes an array of arguments (up to 8 arguments are supported).

Arguments

  • variable function - Name of the function to execute.
  • int id - Array of up to 8 arguments.

Return value

Value returned by the function.

void engine.editor.clearBindings ()

Clears internal buffers with pointers and instances. This function is used for proper cloning of objects with hierarchies, for example, bodies and joints. Should be called before cloning.

int engine.editor.createTerrainIndex (Image mask, Image index, int block)

Creates a 2D mask texture based on the given index texture and updates this index texture.

Arguments

  • Image mask - Terrain mask texture. It must be a 2D texture array.
    Notice
    Compressed, combined and unsigned char image formats are not supported.
  • Image index - Terrain index texture.
  • int block - The ratio of the widths and heights of the mask and index textures. Namely, the value indicating how many times the width and height of the mask texture more than the width and height of the second texture.

Return value

Number of channels of the created mask texture if it is created successfully; otherwise, 0.

int engine.editor.createTerrainMask (Image mask, Image index, int num_materials)

Creates an array of 2D terrain mask textures from the given mask and index textures.

Arguments

  • Image mask - Terrain mask texture. It must be a 2D texture.
    Notice
    Compressed, combined and unsigned char image formats are not supported.
  • Image index - Terrain index texture. It must be a 2D texture.
    Notice
    Compressed, combined and unsigned char image formats are not supported.
  • int num_materials - Number of materials that will be assigned to the created array of 2D terrain mask textures.

Return value

1 if the 2D mask texture array is created successfully; otherwise, 0.

int engine.editor.findNode (string name)

Searches for a node by its name.

Arguments

  • string name - Name of the node.

Return value

Node index if the node is found; otherwise, -1.

string engine.editor.getData ()

Returns user data associated with the editor. This string is written directly into a *.world file. Namely, into the data child tag of the editor tag, for example:
Source code (XML)
<world version="1.21">
	<edtor>
		<data>User data</data>
	</editor>
</world>
		

Return value

User data. Data can contain an XML formatted string.

Node engine.editor.getIntersection (vec3 p0, vec3 p1, int exclude[] = [], variable v)

Traces a line from one point to another to find an object located on that line, skipping objects from a given list. This function takes into account editor-only objects (object handlers). Intersection does not work for disabled objects.

Notice
World space coordinates are used for this function.

Depending on the variable, passed as an argument, the result will be presented as following:

  • WorldIntersection intersection - The WorldIntersection node.
  • WorldIntersectionNormal normal - The WorldIntersectionNormal node.
  • WorldIntersectionTexCoord texcoord - The WorldIntersectionTexCoord node.

Arguments

  • vec3 p0 - Start point of the line.
  • vec3 p1 - End point of the line.
  • int exclude[] - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
  • variable v - Variable.

Return value

The first node found at the line; 0 if there was no intersection.

Node engine.editor.getIntersection (vec3 p0, vec3 p1, variable v)

Traces a line from one point to another to find an object located on that line. This function detects intersection with all editor nodes regardless of them having or not having intersection flag. It also takes into account object handlers. This function does not work for disabled objects.

Notice
World space coordinates are used for this function.

Depending on the variable, passed as the third argument, the result can be presented as the WorldIntersection, WorldIntersectionNormal and WorldIntersectionTexCoord node.

Arguments

  • vec3 p0 - Start point of the line.
  • vec3 p1 - End point of the line.
  • variable v - Variable defining which type of intersection object will be returned:
    • WorldIntersection intersection - The WorldIntersection node.
    • WorldIntersectionNormal normal - The WorldIntersectionNormal node.
    • WorldIntersectionTexCoord texcoord - The WorldIntersectionTexCoord node.

Return value

The first node found at the line; 0 if there was no intersection.

Node engine.editor.getNodeByName (string name)

Returns a node (loaded from the *.world file or belonging to the node list of Unigine Editor) by its name.

Arguments

  • string name - Name of the node.

Return value

Node, if it exists; otherwise, 0.

string engine.editor.getNodeName (int num)

Returns a name of a given node (loaded from the *.world file or belonging to the node list of Unigine Editor) by its index in the list of editor nodes.

Arguments

  • int num - Node index in the list of editor nodes.

Return value

Name of the node.

Node engine.editor.getNode (int num)

Returns a node (loaded from the *.world file or belonging to the node list of Unigine Editor) by its index in the list of editor nodes.
Notice
See also engine.world.getNode() function to get nodes from a script or world file by their unique ID.

Arguments

  • int num - Node index in the list of editor nodes.

Return value

Node with the provided index.

int engine.editor.getNumNodes ()

Returns the number of nodes loaded from the *.world file or belonging to the node list of Unigine Editor.

Return value

Number of nodes in the list.

Player engine.editor.getPlayer ()

Returns the current player used in the Editor mode.

Return value

Current player.

variable engine.editor.get (string var)

Returns a variable from the editor script. Instances of user-defined classes cannot be requested in such a manner.

Arguments

  • string var - Variable name with a namespace, if needed.

Return value

Requested instance.

int engine.editor.isEnabled ()

Returns a value of the the Enabled parameter. The Enabled parameter controls all internal additional engine processing (for example, reloading of textures when their recording time is changed and so on). For example, the Enabled parameter can be set to 0 when using Syncker in order to increase engine performance (as Syncker operates inside the editor environment and can reduce engine performance).

Return value

1 if the Enabled parameter is set; otherwise, 0.

int engine.editor.isLoaded ()

Checks if Unigine Editor is already loaded.

Return value

1 if the editor is loaded; otherwise, 0.

int engine.editor.isNode (Node node)

Checks if a given node belongs to Unigine Editor.

Arguments

  • Node node - Node to check.

Return value

1 if the node belongs to Unigine Editor; otherwise, 0.

int engine.editor.isRuntimeNode (Node node)

Returns a value indicating if the node has been created in runtime. All nodes created in runtime in the world script will be deleted on quitting the world.

Arguments

  • Node node - Node to check.

Return value

1 if the node has been created in runtime; otherwise, 0.

Node engine.editor.loadMesh (string filename)

Loads a mesh from a file. If the mesh is loaded successfully, its node does not belong to any node hierarchy, so be careful and make sure to handle it properly, when it is no longer needed.

Arguments

  • string filename - File with a mesh.

Return value

Node of a type corresponding to the loaded mesh or 0, if the mesh cannot be loaded.

int engine.editor.needReload ()

Returns a value indicating if Unigine Editor should be reloaded.

Return value

1 if the editor should be reloaded; otherwise, 0.

int engine.editor.releaseNode (Node node, int recursion = 0)

Release the current node so it is not owned by Unigine Editor (made orphan).
Notice
After the node is released, it must be appended to one of the scripts. Otherwise, it will cause memory leak.

Arguments

  • Node node - Node to be released.
  • int recursion - A value indicating if the node children will also be released. Pass 1 to release child nodes; otherwise, pass 0.

Return value

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

void engine.editor.reload ()

Reloads the Unigine Editor. This functions updates node hierarchy, updates loaded textures if they were modified, etc.

int engine.editor.removeNode (Node node, int recursion = 0)

Completely removes a given node.

Arguments

  • Node node - Node to remove.
  • int recursion - A value indicating whether the node children will also be removed. Pass 1 to remove the node children; otherwise, pass 0.

Return value

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

int engine.editor.saveMesh (string filename, int id = [])

Saves a mesh into a file. Note that only enabled surfaces will be saved, which makes it possible to save only certain surfaces.

Arguments

  • string filename - File, in which a mesh is going to be stored.
  • int id - Mesh identifier.

Return value

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

void engine.editor.setData (string data)

Updates user data associated with the editor. This string is written directly into a *.world file. Namely, into the data child tag of the editor tag, for example:
Source code (XML)
<world version="1.21">
	<editor>
		<data>User data</data>
	</editor>
</world>
		

Arguments

  • string data - User data to be set. Data can contain an XML formatted string.

void engine.editor.setEnabled (int enabled)

Sets a value of the Enabled parameter that controls all internal additional engine processing (for example, reloading of textures when their recording time is changed and so on). For example, you can set the Enabled parameter to 0 when using Syncker in order to increase engine performance (as Syncker operates inside the editor environment and can reduce engine performance).

Arguments

  • int enabled - 1 to set the Enabled parameter; otherwise, 0.

void engine.editor.setPlayer (Player player)

Sets the current player to be used in the Editor mode.
Notice
Editor player is handled differently than in-game players. Parameters set directly for the player are ignored; instead, Editor player uses Camera parameters set via the interface. (See Editor scripts in data/core/editor folder for implementation.)

Arguments

  • Player player - Player to set as current.

void engine.editor.set (string name, variable variable)

Set a variable in an editor script (this function can be called directly from any other script).

Arguments

  • string name - Variable name.
  • variable variable - Value of the variable.

int engine.editor.swapNodes (Node n0, Node n1)

Swaps positions of given nodes in the list of editor nodes.

Arguments

  • Node n0 - First node to swap.
  • Node n1 - Second node to swap.

Return value

1 if swapping was done successfully; otherwise, 0.
Last update: 2017-07-03
Build: ()