createnode
- Last UpdatedJan 18, 2024
- 3 minute read
The createnode is a powerful statement that can be used inside Command or Coroutine to create an instance of most of the node types at runtime. The node is instantly created, so it is possible to refer to it in the following statement.
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Unsupported node types
The nodes that are containers of other nodes or that have fields whose type depends on other fields cannot be instantiated properly by createnode.
This a list of unsupported nodes.
Defining the instantiated node
The references for the created node are defined by the following createnode fields.
-
name is the name assigned to the instantiated node.
-
nodeType defines the type of the instantiated node.
The name assigned to an instantiated node must be unique, as for any other node.
Assigning type-based initial value to fields
The createnode statement can be used to directly assign value to any of the selected type fields.
All the values assigned to fields using the createnode statement are passed as strings and not resolved by default.
If the value it has to be resolved before being assigned to the field, you will need to surround it with a force resolve tag ([R ]).
Code example
This is a code example for the createnode statement.
<Command name="apm_cmd_addXray">
<!-- creating the mesh node -->
<local name="meshName" type="sstring" value="%0%" />
<local name="mesh" type="sstring" value="mesh_[@apm_xrayXrayMeshes.value.length]" />
<createnode name="[@%mesh%]" nodeType="Mesh" mesh="[R[@%meshName%]]" />
<setfield name="@%mesh%@.set_fade" value="@def:apm.xray.opacity@" />
<!-- assigning material to list of blinking -->
<setfield name="apm_xrayXrayMeshes.value" value="[@apm_xrayXrayMeshes.value.add([@%mesh%])]" />
</Command>
Fields
These are the fields for createnode statement. All other fields that can be added directly to createnode will depend on selected nodeType.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
name |
SSTRING |
Mandatory |
Not set |
The name assigned to the node instance. |
|
nodeType |
SSTRING |
Mandatory |
Not set |
The selected node type. |