diff options
| author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 | 
|---|---|---|
| committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 | 
| commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
| tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Export/PropertyAttribute.cs | |
Diffstat (limited to 'Runtime/Export/PropertyAttribute.cs')
| -rw-r--r-- | Runtime/Export/PropertyAttribute.cs | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/Runtime/Export/PropertyAttribute.cs b/Runtime/Export/PropertyAttribute.cs new file mode 100644 index 0000000..f008483 --- /dev/null +++ b/Runtime/Export/PropertyAttribute.cs @@ -0,0 +1,46 @@ +using System; + +namespace UnityEngine +{ + +// Base class to derive custom property attributes from. Use this to create custom attributes for script variables. +[System.AttributeUsage (AttributeTargets.Field, Inherited = true, AllowMultiple = false)] +public abstract class PropertyAttribute : Attribute +{ +} + +// Attribute used to make a float or int variable in a script be restricted to a specific range. +[System.AttributeUsage (AttributeTargets.Field, Inherited = true, AllowMultiple = false)] +public sealed class RangeAttribute : PropertyAttribute +{ +	public readonly float min; +	public readonly float max; +	 +	// Attribute used to make a float or int variable in a script be restricted to a specific range. +	public RangeAttribute (float min, float max) +	{ +		this.min = min; +		this.max = max; +	} +} + + +// Attribute to make a string be edited with a multi-line textfield +[System.AttributeUsage (AttributeTargets.Field, Inherited = true, AllowMultiple = false)] +public sealed class MultilineAttribute : PropertyAttribute +{ +	public readonly int lines; +	 +	public MultilineAttribute () +	{ +		this.lines = 3; +	} +	// Attribute used to make a string value be shown in a multiline textarea. +	public MultilineAttribute (int lines) +	{ +		this.lines = lines; +	} +	 +} + +} | 
