0

I'm creating a game in unity and I wish to have multiple enums inside one another and making the "dropdowns" visible in unity

public class ItemEnums{
public enum Type
    {
        CraftingMaterial,
        Equipment,
        Food,
        Miscellaneous
    }

    public enum FoodType
    {
        Potion,
        Edible,
        Drink
    }

    public enum EdibleType
    {
        Meat,
        Herbs,
        Fruit,
        Vegetables,
        ProcessedFood
    }



}
[CreateAssetMenu(fileName = "New Item", menuName = "Create new Item")]
[System.Serializable]
public class Items : ScriptableObject
{
    public int id;

    public string itemName;

    [TextArea(3, 3)] public string description;

    public GameObject prefab;
    public Texture icon;

    public int maxStack;
    public float weight;
    public int baseValue;



    public ItemEnums.Type type;

as you can see I instantiated the enum type, but inside the type in the option food I want to instantiate the enum FoodType and inside the FoodType Edible I want to instantiate the EdibleType how do I do that?

Jamelaumn
  • 37
  • 6
  • 2
    You don't. Firstly, don't declare enums inside a class. They should be treated as first class types. Secondly, there's no such thing as nesting enums inside each other. You would have to do something like define a class with three properties of the three enum types and either have a `None` option for when one doesn't apply or make the properties nullable. – jmcilhinney May 28 '23 at 01:55
  • 1
    Create a simple class to hold the enum. Create another class that you'll expose in the inspector (make public) that holds a list of the enum classes. No idea why this question was closed, nothing wrong with it. – Absinthe May 28 '23 at 02:26
  • Oh, I closed because he said it was not a good option to make enums and instantiate inside so to not make a bad question I tried to close it '-' (now reopened) – Jamelaumn May 28 '23 at 02:28
  • 1
    [This Question](https://stackoverflow.com/questions/757684/enum-inheritance ) has an answer which might work for you. – Ashton Way Jun 29 '23 at 01:42

0 Answers0