From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Export/PropertyAttribute.cs | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Runtime/Export/PropertyAttribute.cs (limited to 'Runtime/Export/PropertyAttribute.cs') 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; + } + +} + +} -- cgit v1.1-26-g67d0