From e846c64d6f927879cb8a095e62d773a8d7b3c9f4 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 15 Oct 2020 07:24:10 +0800 Subject: *ability system --- .../Plugins/AdvancedInspector/Attributes/Enum.cs | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Assets/Plugins/AdvancedInspector/Attributes/Enum.cs (limited to 'Assets/Plugins/AdvancedInspector/Attributes/Enum.cs') diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs b/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs new file mode 100644 index 00000000..f9b88281 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs @@ -0,0 +1,68 @@ +using System; + +namespace AdvancedInspector +{ + /// + /// Controls how an enum is handled and displayed. + /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class EnumAttribute : Attribute, IListAttribute + { + private bool masked = false; + + /// + /// Turns a normal enum into a bitfield. + /// Careful, your enum should be properly setup to accepted bitfield input. + /// + public bool Masked + { + get { return masked; } + set { masked = value; } + } + + private EnumDisplay display = EnumDisplay.DropDown; + + /// + /// Forces an enum to be displayed differently. + /// + public EnumDisplay Display + { + get { return display; } + set { display = value; } + } + + private int maxItemsPerRow = 6; + + /// + /// When display is using Button or Checkbox, this is the maximum number of button displayed per rows before creating a new one. + /// + public int MaxItemsPerRow + { + get { return maxItemsPerRow; } + set { maxItemsPerRow = value; } + } + + public EnumAttribute(bool masked) + { + this.masked = masked; + } + + public EnumAttribute(EnumDisplay display) + { + this.display = display; + } + + public EnumAttribute(bool masked, EnumDisplay display) + { + this.masked = masked; + this.display = display; + } + } + + public enum EnumDisplay + { + DropDown, + Button, + Checkbox + } +} \ No newline at end of file -- cgit v1.1-26-g67d0