Set a default value to show in the script properties field.
[System.AttributeUsage(System.AttributeTargets.Field)]public class DefaultValueAttribute : AttributeRemarks
Unless specified by this attribute all fields shown in script properties are initialized to the default value for their type (usually 0 or empty string equivalents.). Note that Vector and Quaternions require an appropriately formatted string to work correctly. Vectors start with ’<’, have 3 or 4 numerical elements seperated by commas, and end with ’>’. Quaternions start with ’[’, have 4 numerical elements seperated by commas, and end with ’]’
Example
[DefaultValue("Default Event")]public string MyString = null;
[DefaultValue(12.34)]public float MyFloat = 1;
[DefaultValue("<1.2,3.4,5.6>")]public Sansar.Vector MyVector;
[DefaultValue("[1.2,3.4,5.6,7.8]")]public Sansar.Quaternion MyQuaternion;
[DefaultValue("(1.2,3.4,5.6,7.8)")]public Sansar.Color MyColor;
[DefaultValue(true)]public bool MyBool;
[DefaultValue(2)][Range(-20, 5)]public int myInt;Members at a glance
| Kind | Members |
|---|---|
| Constructors | DefaultValueAttribute |
Constructors
DefaultValueAttribute
public DefaultValueAttribute(bool value)Set a default bool value to show in the script properties for this field. Without the DefaultValue attribute bools default to ‘false’.
| Parameter | Type | Description |
|---|---|---|
value | bool | The default boolvalue to show in script properties. |
Example
[DefaultValue(true)]public bool MyBool;public DefaultValueAttribute(byte value)Set a default byte value to show in the script properties for this field. Without the DefaultValue attribute bytes default to 0.
| Parameter | Type | Description |
|---|---|---|
value | byte | The default byte value to show in script properties. |
Example
[DefaultValue(0x00C9)]public byte MyField;public DefaultValueAttribute(double value)Set a default double value to show in the script properties for this field. Without the DefaultValue attribute doubles default to 0.0.
| Parameter | Type | Description |
|---|---|---|
value | double | The default double value to show in script properties. |
Remarks
Script properties only support floats, this constructor is provided for convenience and values will be converted to floats.
Example
[DefaultValue(12.34)]public double MyField;public DefaultValueAttribute(params double[] value)Set a default double value to show in the script properties for this field. Without the DefaultValue attribute doubles default to 0.0.
| Parameter | Type | Description |
|---|---|---|
value | double[] | The default double value to show in script properties. |
Remarks
Script properties only support floats, this constructor is provided for convenience and values will be converted to floats.
Example
[DefaultValue(1.3, 2.4, 3.5)]public Vector MyField;public DefaultValueAttribute(short value)Set a default short value to show in the script properties for this field. Without the DefaultValue attribute shorts default to 0.
| Parameter | Type | Description |
|---|---|---|
value | short | The default short value to show in script properties. |
Example
[DefaultValue(123)]public short MyField;public DefaultValueAttribute(int value)Set a default int value to show in the script properties for this field. Without the DefaultValue attribute ints default to 0.
| Parameter | Type | Description |
|---|---|---|
value | int | The default int value to show in script properties. |
Example
[DefaultValue(123)]public int MyField;public DefaultValueAttribute(long value)Set a default long value to show in the script properties for this field. Without the DefaultValue attribute longs default to 0.
| Parameter | Type | Description |
|---|---|---|
value | long | The default long value to show in script properties. |
Example
[DefaultValue(123)]public long MyField;public DefaultValueAttribute(float value)Set a default float value to show in the script properties for this field. Without the DefaultValue attribute floats default to 0.0.
| Parameter | Type | Description |
|---|---|---|
value | float | The default float value to show in script properties. |
Remarks
Script properties only support up to 32bit int, this constructor is provided for convenience and values will be converted to 32bit int.
Example
[DefaultValue(12.34)]public float MyField;public DefaultValueAttribute(string value)Set a default string value to show in the script properties for this field. Without the DefaultValue attribute strings default to an empty string.
| Parameter | Type | Description |
|---|---|---|
value | string | The default value in string form for strings, quaternions and vector fields. |
Remarks
The string DefaultValue attribute can be used to set Vector and Quaternions with an appropriately formatted string. Vectors start with ’<’, have 3 or 4 numerical elements seperated by commas, and end with ’>’. Quaternions start with ’[’, have 4 numerical elements seperated by commas, and end with ’]’
Example
[DefaultValue("Default Event")]public string MyString = null;
[DefaultValue("<1.2,3.4,5.6>")]public Sansar.Vector MyVector;
[DefaultValue("[1.2,3.4,5.6,7.8]")]public Sansar.Quaternion MyQuaternion;
[DefaultValue("(1.2,3.4,5.6,7.8)")]public Sansar.Quaternion MyQuaternion;Generated from the Sansar 47.10.0 client ScriptApi snapshot.