setfield
- Last UpdatedMay 02, 2023
- 2 minute read
The setfield statement assigns an arbitrary value to a node parameter. It is used inside a Command node node.
Important This statement is deprecated. We advise you to use the set statement instead of the legacy setfield and setlocal, as set works for both locals and fields. This makes the code more readable. Contrary to what setfield does, set resolves the parameters only once, which allows it to perform operations on types that might contain reserved characters, such as SJSON and others.
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 |
|
|
|
|
|
|
Code example
This is a code example for the setfield statement.
<command name="showmenu">
<setfield field="menu.position" value="@global.mousePosition" />
<setfield field="menu.fadeIn" value="0.5" />
<setfield field="menu_timer2.start" value="true" />
<setvariable variable="menuvisible" value="true"/>
<changecontext context="setb"/>
<setfield field="menu_cont.start"/>
</command>
Position
The setfield statement can be used only inside a Command node node.
Fields
These are the fields for setfield statement.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
condition |
sstring |
Optional |
No default value |
Applies a condition to the function execution. |
|
name |
sstring |
Mandatory |
No default value |
Defines the node field to be assigned. The syntax is the usual syntax to indicate a node parameter. |
|
op |
sstring |
Optional |
No default value |
If set to Noresolve, the value content is directly transferred into the field without being resolved. |
|
value |
sstring |
Optional |
No default value |
The value to be assigned to the field. If the field is a SEVENT field, there is no need to indicate a value because the scene manager assigns a timestamp. |