Nested enum or something else

Hello! I have categories and types, they are created in the form of enum. This is convenient since a drop-down list is created in the inspector. But I want the categories to be categorized, how do I implement this? At the same time, it is necessary to preserve the ability to display elements in the drop-down list.

Depends on how you want type of category to be displayed. You can put similar enum values next to each, but if you want some kind of header before each category group, then you’ll need some hefty editor scripting.

It is possible to write custom editors in Unity to make the inspector for your object work kind of however you want. Maybe have one dropdown for the category, and then reveal more data fields based on the specific category that was selected. (Kind of like how Unity’s Button component shows and hides different fields depending on what you select in the “Transition” dropdown.)

If you don’t want to go to that effort, though, then you are limited to the default type support that Unity already has. In that case, I believe your only option for a dropdown menu is just a regular enum, and IIRC the options are always sorted alphabetically.

You might consider a naming convention where each value in the enum starts with a prefix that indicates its category

It doesn’t really matter how they are displayed. Look, I need categories and types. Types must be categorized. I need to use these types in another place, for example, on objects in order to establish their type. Until now, I had just types and I had enough enum Types {x1, x2} and on the object I just selected a type for it from the list. But now we also need categories … That is, at the facility I need to choose which category from applies and, accordingly, the types of this category should be established so that I can choose them.

Good idea to see the button component, thanks.