engine.editor Functions
This class provides functionality for the editor script that loads and manages the hierarchy of nodes displayed in the editor.
Editor Class
Members
int engine.editor.isLegacyMode()
Returns a value indicating if the legacy editor is loaded.Return value
1 if the legacy editor is loaded; otherwise, 0.int engine.editor.isLoaded()
Returns a value indicating if the editor is already loaded.Return value
1 if the editor is loaded; otherwise, 0.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.
int engine.editor.isEnabled()
Returns a value of 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.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:<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.
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:<world version="1.21">
<edtor>
<data>User data</data>
</editor>
</world>
Return value
User data. Data can contain an XML formatted string.void engine.editor.reload()
Reloads the Unigine Editor. This functions updates node hierarchy, updates loaded textures if they were modified, etc.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.void engine.editor.setPlayer(Player player)
Sets the current player to be used in the Editor mode.Arguments
- Player player - Player to set as current.
Player engine.editor.getPlayer()
Returns the current player used in the editor.Return value
Current player.void engine.editor.addEditorPlayer(Player player)
Adds another editor player.Arguments
- Player player - Player instance.
void engine.editor.removeEditorPlayer(Player player)
Removes a given player from the editor.Arguments
- Player player - Player instance.
int engine.editor.isEditorPlayer(Player player)
Returns a value indicating if the given player is an Editor player.Arguments
- Player player - Player instance.
Return value
1 if the Player is an Editor player; otherwise, 0.int engine.editor.getNumNodes()
Returns the number of nodes loaded from the *.world file or belonging to the node list of the editor.Return value
Number of nodes in the list.int engine.editor.findNode(string name)
Searches an editor node by its name.Arguments
- string name - Name of the node.
Return value
Node index if the node is found; otherwise, -1.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.Arguments
- int num - Node index in the list of editor nodes.
Return value
Node with the provided index.Node engine.editor.getNodeByName(string name)
Returns the editor node by its name.Arguments
- string name - Node name.
Return value
Node, if it is in the list of editor nodes; otherwise, 0.Node engine.editor.getNodeById(int node_id)
Returns the editor node by its identifier.Arguments
- int node_id - Node ID.
Return value
Node, if it is in the list of editor nodes; otherwise, 0.int engine.editor.findNodeById(int node_id)
Searches for the node by its ID.Arguments
- int node_id - Node ID.
Return value
Node index if the node is found; otherwise, -1.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.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.int engine.editor.getNodeIndex(Node node)
Returns the index of the given node in the list of editor nodes. This function is useful when you need to change the World Hierarchy in the editor.Arguments
- Node node - Node.
Return value
Node index.void engine.editor.setNodeIndex(Node node, int index)
Sets a new index for the given node in the list of editor nodes. This function is used to change the World Hierarchy in the editor.Arguments
- Node node - Node.
- int index - Node index.
int engine.editor.isNode(Node node)
Checks if a given node belongs to the editor.Arguments
- Node node - Node to check.
Return value
1 if the node belongs to the editor; otherwise, 0.int engine.editor.isRuntimeNode(Node node)
Returns a value indicating if the node has been created at run time. All nodes created at run time in the world script will be deleted on quitting the world. Such nodes will not be saved to a .world file on world_save command.Arguments
- Node node - Node to check.
Return value
1 if the node has been created at run time; otherwise, 0.int engine.editor.addNode(Node node, int is_runtime = 0)
Appends a given node to the editor.Arguments
- Node node - Node instance.
- int is_runtime - A value indicating if the node should be deleted on quitting the world: 1 to delete the node; 0 to save the node. Runtime nodes will not be saved to a .world file on world_save command.
Return value
1 if the node is added successfully; otherwise, 0.int engine.editor.removeNode(Node node, int with_children = 0)
Removes a given node from the editor.Arguments
- Node node - Node to remove.
- int with_children - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.
Return value
1 if the node is removed successfully; otherwise, 0.int engine.editor.releaseNode(Node node, int with_children = 0)
Release the current node so it is not owned by Unigine Editor (made orphan).Arguments
- Node node - Node to be released.
- int with_children - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.
Return value
1 if the node is released successfully; otherwise, 0.int engine.editor.updateNode(Node node, int with_children = 0)
Updates the target node.Arguments
- Node node - Node instance.
- int with_children - 1 — update the target parent nodes along with all their children nodes; 0 — update the target parent nodes without their children nodes.
Return value
1 if the nodes array was updated successfully; otherwise, 0.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.isVariable(string name)
Returns a value indicating if the given variable exists in the editor script.Arguments
- string name - Variable name.
Return value
1 if the variable exists; otherwise, 0.int engine.editor.isFunction(string name, int num_args)
Returns a value indicating if the given function with the specified number of arguments exists in the editor script.Arguments
- string name - Function name.
- int num_args - Number of function arguments.
Return value
1 if the function exists; otherwise, 0.void engine.editor.set(string function, Variable value)
Sets a variable in a editor script (this function can be called directly from any other script).Arguments
- string function - Variable name.
- Variable value - Value of the variable.
Variable engine.editor.get(string function)
Returns a variable from the editor script. Instances of user-defined classes cannot be requested in such a manner.Arguments
- string function - Variable name with a namespace, if needed.
Return value
Requested instance.Variable engine.editor.call(Variable function)
Executes a function of the editor script 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 arg0)
Executes a function of the editor script from an external script. The function should take one argument.Arguments
- Variable function - Name of the function to execute.
- Variable arg0 - 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 the editor script 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 the editor script 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 the editor script 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 the editor script 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 arg4, Variable arg5)
Executes a function of the editor script 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 arg4 - Argument of the function.
- Variable arg5 - Argument of the function.
Return value
Value returned by the function.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.
Depending on the variable, passed as an argument, the intersection result will be presented as follows:
- 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 nodes to exclude; all these nodes will be skipped while checking for intersection.
- Variable v - Variable into which information on the intersection will be saved.
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 takes into account editor-only objects (object handlers). Intersection does not work for disabled objects.
Depending on the variable, passed as an argument, the intersection result will be presented as follows:
- 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.
- Variable v - Variable into which information on the intersection will be saved.
Return value
The first node found at the line; 0 if there was no intersection.Variable engine.editor.call(Variable function, int id = [])
Executes a function of the editor script 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.