• 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 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 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 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 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 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by BennyXUNITY · Jan 09 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 at 12:28 AM 0
Share

Thank you for your answer.

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

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

123 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

Related Questions

Move object when player reach trigger 2 Answers

Searching throguh array in custom inspector 0 Answers

Animation while walking 1 Answer

Help! This script is causing my Enemy to die on Spawn?? 2 Answers

How to access Leap motion's bone direction property within C# script ? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges