- Home /
How can I refactor an enum so that it is still available in the inspector?
I am trying to use an enum so that it is available in the inspector. This code works:
public ArmorTypeEnum ArmorType;
public enum ArmorTypeEnum { Light, Medium, Heavy };
How can I refactor it into a single line?
How can I make ArmorTypeEnum
private while keeping ArmorType
public?
Answer by DiegoSLTS · Mar 19, 2015 at 01:43 AM
You can't do that in one line, the first line is a declaration of a variable called ArmorType of type "ArmorTypeEnum", it will have a value of Light, Medium or Heavy. The second line is the definition of a enum, setting possible values for that enum and a type to group all the values.
I think you can't do the private/public thing either, if you have a public variable of type ArmorTypeEnum you have to make the enum public so other scripts know what that type is.
Your answer
![](https://koobas.hobune.stream/wayback/20220613190603im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Exposing Enums in Custom Inspector 1 Answer
Enum become integer in the inspector 1 Answer
Automatically create enum based on class children types? (C#) 1 Answer
Drop-down enum pauses player - must it be so? 1 Answer
Change Enum Contents 1 Answer