Unity extension makes the enum view a multi-marquee

Source: Internet
Author: User

:

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.