ScriptObject
- Last UpdatedMay 27, 2024
- 2 minute read
A ScriptObject node is created when an XRS Class is instanced. It represents a specific XRS class instance and all its non-static public methods and variables.
Platform support
This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P Hololens 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 examples
Code example for XRS Script code.
namespace XR
{
class TestClass
{
public int val1;
public int val2;
public int val3;
test ()
{
val2 = val1+2; // val1 has been initialized from xml when creating the node
val3 = 3;
}
}
}
Code example for XML Script code.
<ScriptObject name="testObject" class="XR::TestClass" val1=”3”/>
//val1=3
//val2=5;
//val3=3;
A ScriptObject is created by assigning a name and a class, with the syntax namespaceName::className. Public parameters initialization is optional.
Notice that parameters initialization overrides class constructor initializations, if present.
ScriptObject fields
These are the fields for ScriptObject node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > ScriptObject
|
Fields |
Type |
Use |
Default |
Description |
|---|---|---|---|---|
|
methodName |
SScriptMethod |
Optional |
|
Represents a non-static public class method defined in a XRS Script class definition. A new field is created for each method methodName. |
|
variableName |
SScriptVariable |
Optional |
|
Represents a non-static public class variable defined in a XRS Script class definition. A new field is created for each variable variableName. |