Unity-Editor-Toolbox
Unity-Editor-Toolbox copied to clipboard
[Feature Request] - Enum Categorization
Hi, I'm back annoying you with yet another feature request that might be cool. This time I'm talking about enum categorization, it would be useful to have a way to assign categories/groups to enum values and be able to fold them and/or filter them in the inspector, would be useful to have more order, especially if enums start having a lot of options.
Hi!
Can you provide a use-case for me? How do you think this feature should work with an example enum, etc. In the meantime I suggest using 'SearchableEnumAttrbiute', it's a perfect way to pick enums from larger lists.
Well, the thing isn't just to search in bigger enums, but categorize them, or tag them for specific selection
Example enum:
enum ChoosableClass
{
[EnumCategory("Ranged")] Gunner,
[EnumCategory("Ranged")] Archer,
[EnumCategory("Ranged")] Mage,
[EnumCategory("Melee")] Warrior,
[EnumCategory("Melee")] Berserker,
[EnumCategory("Melee")] Tank
}
Example filtering:
[FilteredEnum("Melee")] ChoosableClass meleeClass;
This is just a simple case, but as you can see everything fits under the ChoosableClass enum, but some things have different categories, and maybe I wanna be able to choose in some cases between just specific categories of that single enum, hope this makes more sense and is more specific
Yes, I can implement something similar.
Alternatively and something more lightweight you can use Flag-based "categories" like this:
[System.Flags]
public enum ChoosableClass
{
Nothing = 0,
Gunner = 1,
Archer = 2,
Mage = 4,
Warrior = 8,
Berserker = 16,
Tank = 32,
Ranged = Gunner | Archer | Mage,
Melee = Warrior | Berserker | Tank,
Everything = ~0
}
...
ChoosableClass.Ranged.HasFlag(pickedClass);
I can implement drawer that allows only enum values that match provided flag.
So basically "ranged" is never picked but is instead used to check if what I selected is within "ranged", correct? If so I'll see if this is something that could work for my use case