• 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 kurczake · Jan 09, 2021 at 10:01 PM · scripting beginner

Hide enum to select.

Hi!

My structure contains an enum:

public enum PlayerDisposition : int { Good = 0, Evil = 1, Neutral = 2 }

Is it possible to block the selection of the "Good" option from the inspector's level?

Greetings!

Comment
Add comment · Show 4
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 kurczake · Jan 09, 2021 at 10:17 PM 0
Share

I was able to do this from the Player class in CustomEditor, but I would like to do it directly in the structure.

avatar image Hellium · Jan 09, 2021 at 10:28 PM 0
Share

What is the point of exposing the enum in the inspector if you prevent it from being changed?

avatar image kurczake · Jan 09, 2021 at 10:36 PM 0
Share

Because for certain types of characters I would like to assign different values (the demon can only be bad). I would like to hide this for structure because I use lists of structures in classes.

avatar image Hellium kurczake · Jan 09, 2021 at 10:41 PM 0
Share

Again, why exposing this in editor then?

Whenever something needs the value of the disposition, hard code the return value to Evil

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by BennyXUNITY · Jan 09, 2021 at 11:18 PM

So you only want evil and neutral to be selectable?

That I personally don't know, but if you want to hide the whole thing from the inspector and don't need the enum to be public you should just set it to private.

If you need it to be public but want to hide the whole thing anyway just put [HideInInspector] before the variable.

For Example:

public enum PlayerDisposition : int { Good = 0, Evil = 1, Neutral = 2 }
[HideInInspector] 
PlayerDisposition variable;

Comment
Add comment · Show 1 · 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 kurczake · Jan 10, 2021 at 12:28 AM 0
Share

Thank you for your answer.

I don't want to hide the whole variable just individual options.

avatar image
0

Answer by Renardjojo · Mar 31 at 07:04 PM

Hey you can find solution here. This solution hide only selected field of your enum.

 public enum ETeam
 {
     Team1 = 0,
     Team2 = 1,
     [InspectorName(null)]
     TeamCount
 }

Here the result: Example


here.png (9.0 kB)
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

124 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Inherit functions that work properly 1 Answer

Scene tree text generation 1 Answer

Gas Fuel Implementation 0 Answers

BOLT FlowStateMachine for entire scene? 1 Answer

Is my controller script good? 2 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