DefaultValueAttribute

DefaultValueAttribute Class

Set a default value to show in the script properties field.

Syntax

[System.AttributeUsage(System.AttributeTargets.Field)]
public class DefaultValueAttribute : Attribute

Remarks

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

C# 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(true)]
             public bool MyBool;
            
             [DefaultValue(2)]
             [Range(-20, 5)]
             public int myInt;

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Members

See Also: Inherited members from Attribute.

Public Constructors

 
Set a default bool value to show in the script properties for this field. Without the DefaultValue attribute bools default to 'false'.
 
Set a default byte value to show in the script properties for this field. Without the DefaultValue attribute bytes default to 0.
 
Set a default double value to show in the script properties for this field. Without the DefaultValue attribute doubles default to 0.0.
 
Set a default short value to show in the script properties for this field. Without the DefaultValue attribute shorts default to 0.
 
Set a default int value to show in the script properties for this field. Without the DefaultValue attribute ints default to 0.
 
Set a default long value to show in the script properties for this field. Without the DefaultValue attribute longs default to 0.
 
Set a default float value to show in the script properties for this field. Without the DefaultValue attribute floats default to 0.0.
 
Set a default string value to show in the script properties for this field. Without the DefaultValue attribute strings default to an empty string.

Member Details

DefaultValueAttribute Constructor

Set a default bool value to show in the script properties for this field. Without the DefaultValue attribute bools default to 'false'.

Syntax

public DefaultValueAttribute (bool value)

Parameters

value
The default boolvalue to show in script properties.

Remarks

 

Example

C# Example
            [DefaultValue(true)]
            public bool MyBool;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default byte value to show in the script properties for this field. Without the DefaultValue attribute bytes default to 0.

Syntax

public DefaultValueAttribute (byte value)

Parameters

value
The default byte value to show in script properties.

Remarks

 

Example

C# Example
            [DefaultValue(0x00C9)]
            public byte MyField;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default double value to show in the script properties for this field. Without the DefaultValue attribute doubles default to 0.0.

Syntax

public DefaultValueAttribute (double value)

Parameters

value
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

C# Example
            [DefaultValue(12.34)]
            public double MyField;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default short value to show in the script properties for this field. Without the DefaultValue attribute shorts default to 0.

Syntax

public DefaultValueAttribute (short value)

Parameters

value
The default short value to show in script properties.

Remarks

 

Example

C# Example
            [DefaultValue(123)]
            public short MyField;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default int value to show in the script properties for this field. Without the DefaultValue attribute ints default to 0.

Syntax

public DefaultValueAttribute (int value)

Parameters

value
The default int value to show in script properties.

Remarks

 

Example

C# Example
            [DefaultValue(123)]
            public int MyField;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default long value to show in the script properties for this field. Without the DefaultValue attribute longs default to 0.

Syntax

public DefaultValueAttribute (long value)

Parameters

value
The default long value to show in script properties.

Remarks

 

Example

C# Example
            [DefaultValue(123)]
            public long MyField;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default float value to show in the script properties for this field. Without the DefaultValue attribute floats default to 0.0.

Syntax

public DefaultValueAttribute (float value)

Parameters

value
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

C# Example
            [DefaultValue(12.34)]
            public float MyField;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

DefaultValueAttribute Constructor

Set a default string value to show in the script properties for this field. Without the DefaultValue attribute strings default to an empty string.

Syntax

public DefaultValueAttribute (string value)

Parameters

value
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

C# 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;
            

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.