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
0
Question by Sgt Crapgame · Jul 24, 2012 at 03:28 PM · editorinspectoreditorguilayout

Custom Inspector with field like Camera culling mask

I'm currently working on a custom inspector for one of my script. I need to be able to select one or more layers (for some filters behaviour) and so I try to have a field exactly similar to the 'Culling mask' in the Camera inspector. I tried with EditorGUILayout.EnumMaskField and EditorGUILayout.MaskField without any success despite the fact is apparently the class to use... If someone has some code example or a solution to this problem he will be welcome :)

thanks in advance

Comment
Add comment · Show 6
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 irrationalistic · Jul 24, 2012 at 05:38 PM 0
Share

Have you tried http://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.LayerField.html ?

avatar image Sgt Crapgame · Jul 24, 2012 at 08:07 PM 0
Share

Yes but the LayerField does not allow multiple selections (and propose to 'Add a Layer'). It's not what I expect :( I need to be able to select 0, 1, 2, ... or all layers like in the 'culling mask' field of the Camera Inspector

thanks

avatar image irrationalistic · Jul 24, 2012 at 08:12 PM 0
Share

Ah I see. Seems like you'd really want to use the enum mask field so you can pass in the list of layers. What was the issue with the enum mask field?

avatar image Sgt Crapgame · Jul 24, 2012 at 08:20 PM 0
Share

perhaps I'm stupid but I did not found an enum corresponding to the layers... I searching in all the enum in the documentation

avatar image irrationalistic · Jul 24, 2012 at 08:26 PM 0
Share

Yeah, I don't think there is a list exactly, but since you know the max number of layers is 32 (0 - 31 including builtin and custom), you can loop through all those numbers and use Layer$$anonymous$$ask.LayerToName(index) to get a full text list of all layers and exclude ones that have no name. If you select something from the enum, it should be represented by the layer ID from the loop. Annoying, but it should work.

Show more comments

2 Replies

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

Answer by irrationalistic · Jul 24, 2012 at 08:31 PM

My only other suggestion is to utilize the default drawing of the inspector for only that one field assuming it's set as a LayerMask variable. Just add the HideInInspector directive to all the public variables you want to have custom editor fields for and do all your custom drawing. Then, at the end of the ongui stuff, add the drawdefaultinspector which will draw your default inspector stuff, essentially only drawing your layer field mask using the built-in method. Also awkward, but much easier to edit.

Comment
Add comment · 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
0

Answer by Sgt Crapgame · Jul 25, 2012 at 01:08 AM

I implemented my inspector as you describe ([HideInInspector] + call to DrawDefaultInspector()) and it works as expected. Thank you very much

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Updating editor GUI on button press 2 Answers

EditorGUILayout.ObjectField cannot be changed. 1 Answer

Custom Inspector - How to add functionality? 1 Answer

How could I merge 2 components' inspectors through a custom editor? 2 Answers

How can I override the default inspector editor with my own? 3 Answers


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