Create exported enum variable with UI like CollisionLayer

Godot Version

4.3

Question

I was playing Animal Crossing and thinking about how furniture and clothing can have different themes, and differing numbers of those themes. As a made up example, a model castle might have the Historical and Fairy-tale themes, while a toy dragon might just have the Fairy-tale theme.

After searching (since I’m still relatively unknowledgeable), I found that I can use and export Enums to implement this sort of thing quite easily, but the way it exports as a long list of every option in the Enum makes me wonder: is there a way to set up an exported variable so it has the same selector as the CollisionLayer and CollisionMask variables (pictured below), or are those built-in options made only for these variables?

image

This is an interesting idea. Sadly when you name the layers, you just get the list again, not a nice interface like with numbers… How many styles are you thinking of having?

Apologies for the delayed response, Google filtered the email notification I got so I didn’t see it.

Right now it’s more a theoretical question, though I do have game ideas in the works that this could be applied to (for example, my current main project involves museums and collections). I suppose a single digit number of “styles” would be a good starting point.

You (might) want @export_flags

Though, collision layer and mask use this because it can set multiple layers or masks on/off. If you only want one style set at a time, you should stick to enums.


This is implemented as a “bitset”, binary being used to store up to 32 true or false values. When using the @export_flags you will get an int instead of an enum, checking values involves binary operations like this to check one value my_flag & 0b1000 != 0

I wrote a similar example as a advanced recommendation to replace an Array[bool] type.