:
Define attribute Description attributes (because no data is described, so that the drawing class is drawn so that it is empty)
using Unityengine; using System.Collections; Public class Enumflagsattribute:propertyattribute {}
Custom Attribute Drawing class:
usingUnityengine;usingSystem.Collections;usingUnityeditor; [Custompropertydrawer (typeof(Enumflagsattribute))] Public classEnumflagsattributedrawer:propertydrawer { Public Override voidOngui (Rect position, Serializedproperty property, Guicontent label) {/** Draw Multi-Value enumeration selection box, 0 all unselected, 1 all selected, others are enumerated and * enumeration value = Current Subscript value ^ 2 * default [0^2 = 1, 1 ^2 = 2, 4, 16, .... .] */Property.intvalue=Editorgui.maskfield (position, label, Property.intvalue, Property.enum Names); Debug.Log ("the value of the layer:"+property.intvalue); }}
Component:
using Unityengine; using System.Collections; Public enum Layermeskenum { Layer1, Layer2, Layer3, Layer4,}publicclass mycompoment:monobehaviour { [enumflagsattribute] public layermeskenum layer;}
Project structure:
Unity extension makes the enum view a multi-marquee