Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by MasterLetch · Jan 28, 2013 at 02:01 AM · inspectorenum

Flagged Enum representation in Inspector

I am curious to know. I have looked into making serializable objects and fields and it loks like the only thing stopping someone from making a enum with flags (like layermasks) is calculating the enums fields from an int.

so if someone could help me write an editor script in C# to display an enum and a way to get a function to run between the enum and the inspector. I'd be able to put together something that does just that.

things i don't quite know:

  1. how to use the custom editor.

  2. what aspects go under the creation of a new window or simply changing the inspector.

  3. how to create an attribute.

  4. whether or not the enum needs to be serialized or the variable of that type.

any help would be greatly appreciated

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Jan 28, 2013 at 02:07 AM

I guess instead of EnumPopup you might just want to use EnumMaskField ;)

Keep in mind that you have to cast the return type into your enum type since C# uses strong types.

edit
EnumMaskField of course is also available without layouting, but in the inspector you probably want to use GUILayout.

There's also a general MaskField but the EnumMaskField is actually more powerful since you can even specify combined items:

 public enum ETestEnum
 {
     None          = 0, // 0000

     Left          = 1, // 0001
     Center        = 2, // 0010
     Right         = 4, // 0100
     
     LeftAndRight  = 5, // 0101
     CenterLeft    = 3, // 0011
     CenterRight   = 6, // 0110
     
     All           = 7, // 0111
 }

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MasterLetch · Jan 28, 2013 at 02:31 AM 0
Share

well that's part of what i need (can't believe its right there so easy) but how exactly is that editor used (since all examples are in java script its a bit hard to read)

avatar image MasterLetch · Jan 28, 2013 at 02:33 AM 0
Share

and there is also the placement. do you have to serialize? and if so... what do you serialize?

avatar image Bunny83 · Jan 28, 2013 at 02:44 AM 0
Share

What placement? Do you talk about a custom editor aka inspector or about an EditorWindow? Enums are serialized automatically by Unity, so just change the value on a script instance and Unity will take care of the rest. If you want to implement a multiple object editor you have to use the serializedObject property of your Editor.

I don't have the time to post a whole editor example. I need some sleep ;)

avatar image MasterLetch · Jan 28, 2013 at 02:55 AM 0
Share

thank you for the quick reply, I'll figure it out from here thanks have a goodnight :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

c# enum wont show in inspector 3 Answers

Insert enum breaking existing inspector values 2 Answers

Restrict which types of an Enum can be selected in inspector. 5 Answers

How can i show enum description in Inspector? 2 Answers

Instantiate GameObject on Enum Selection from Inspector 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges