- Home /
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!
I was able to do this from the Player class in CustomEditor, but I would like to do it directly in the structure.
What is the point of exposing the enum in the inspector if you prevent it from being changed?
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.
Again, why exposing this in editor then?
Whenever something needs the value of the disposition, hard code the return value to Evil
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;
Thank you for your answer.
I don't want to hide the whole variable just individual options.
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: