This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
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 class provides functionality for the editor script that loads and manages the hierarchy of nodes displayed in the editor.

Notice
C++ methods running editor script functions are described in the Engine class reference.

Editor Class

Members


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.

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.

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.

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.

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.

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.

Node engine.editor.getIntersection(Vec3 p0, Vec3 p1, Vector<Node> exclude, int 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.
  • Vector<Node> exclude - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
  • int 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, int 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 v - Variable.

Return value

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

engine.editor.getIntersection()

Arguments

    Return value

    Returns the first intersected node smart pointer if found; otherwise, NULL pointer.

    engine.editor.getIntersection()

    Arguments

      Return value

      The first intersected node smart pointer if found; otherwise, NULL pointer.

      Node engine.editor.getIntersection(Vec3 p0, Vec3 p1, Vector<Node> exclude, Vec3 ret_point, vec3 ret_normal, vec4 ret_texcoord, int ret_index, int ret_surface)

      Searches for all of the nodes intersecting the line. The node closest to the start point is returned.

      Arguments

      • Vec3 p0 - Coordinates of the line start point.
      • Vec3 p1 - Coordinates of the line end point.
      • Vector<Node> exclude - Array of the objects to exclude; all these objects will be skipped while checking for intersection.
      • Vec3 ret_point - Intersection point of the line and object.
      • vec3 ret_normal - Normal vector to the intersection point.
      • vec4 ret_texcoord - Texture coordinates of the intersection point (vec4, where vec4.xy is for the first (0) UV channel, vec4.zw is for the second (1) UV channel).
      • int ret_index - Intersected triangle number.
      • int ret_surface - Intersected surface number.

      Return value

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

      Node engine.editor.getIntersection(Vec3 p0, Vec3 p1, Vec3 ret_point, vec3 ret_normal, vec4 ret_texcoord, int ret_index, int ret_surface)

      Searches for all of the nodes intersecting the line. The node closest to the start point is returned.

      Arguments

      • Vec3 p0 - Coordinates of the line start point.
      • Vec3 p1 - Coordinates of the line end point.
      • Vec3 ret_point - Intersection point of the line and object.
      • vec3 ret_normal - Normal vector to the intersection point.
      • vec4 ret_texcoord - Texture coordinates of the intersection point (vec4, where vec4.xy is for the first (0) UV channel, vec4.zw is for the second (1) UV channel).
      • int ret_index - Intersected triangle number.
      • int ret_surface - Intersected surface number.

      Return value

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

      engine.editor.getIntersection()

      Arguments

        Return value

        The first intersected node smart pointer if found; otherwise, NULL pointer.

        engine.editor.getIntersection(Vec3 p0, Vec3 p1)

        Searches for all of the nodes intersecting the line. The node closest to the start point is returned. The intersection result will be presented as WorldIntersectionNormal.

        Arguments

        • Vec3 p0 - Start point of the line.
        • Vec3 p1 - End point of the line.

        Return value

        int engine.editor.isLoaded()

        Checks if Unigine Editor is already loaded.

        Return value

        1 if the editor is loaded; otherwise, 0.

        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.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.

        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.

        Node engine.editor.getNodeByName(string name)

        Returns the editor node by its name.

        Arguments

        • string name - Name of the node.

        Return value

        Node, if it is in the list of editor nodes; otherwise, 0.

        void engine.editor.setNodeIndex(Node n, int index)

        Sets a new index for the given node in the list of editor nodes. This function is used to change the nodes hierarchy in the editor.

        Arguments

        • Node n - Node.
        • int index - Node index.

        int engine.editor.getNodeIndex(Node n)

        Returns the index of the given node in the list of editor nodes. This function is useful when you need to change the nodes hierarchy in the editor.

        Arguments

        • Node n - Node.

        Return value

        Node index.

        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.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.

        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.

        Player engine.editor.getPlayer()

        Returns the current player used in the editor.

        Return value

        Current player.

        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.

        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.

        void engine.editor.addEditorPlayer(Player player)

        Adds another editor player.

        Arguments

        • Player player - Player instance.

        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 instance.
        • 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 added successfully; otherwise, 0.

        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.

        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.

        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.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.

        int engine.editor.findNodeById(int node_id)

        Searches for the node by ID.

        Arguments

        • int node_id - Node ID.

        Return value

        1 if the node is found; otherwise, 0.

        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 - 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.

        void engine.editor.reload()

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

        void engine.editor.removeEditorPlayer(Player player)

        Removes a given player from the editor.

        Arguments

        • Player player - Player instance.

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

        Removes a given node from the editor.

        Arguments

        • Node node - Node to remove.
        • int recursion - 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.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.updateNode(Node node, int recursion = 0)

        Updates the target node.

        Arguments

        • Node node - Node instance.
        • int recursion - 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.
        Last update: 2017-07-03
        Build: ()