You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At this time, exporting enums in GDScript is very cumbersome. In order for the enums' names to be visible in the editor, you must specify a set of strings to be displayed for each value. This requires a hardcoded list of strings that must be updated as the enum changes over time. Either that, or a Dictionary mapping must be made and then used in a _get_property_list() override in a tool script (which, in turn, necessitates an implementation of _set() and _get(). This can amount to as much as 20 extra lines of code + converting it to a tool script JUST to make an enum value automatically updated in the Inspector.
This change would allow you to define enum exports based on an enum's identifier and using an optional string prefix to filter out string content from the keys, similar to the way the engine treats property groups.
enum Elements {
ELEM_FIRE,
ELEM_ICE
}
export(int, Elements, "ELEM_") var element = ELEM_FIRE
This would then display "Fire" and "Ice" as options within the editor as it would filter out the content. If you wished to change the order, you could just change the ordering within the enum.
The text was updated successfully, but these errors were encountered:
Turns out this was largely already done in 3.1! All you had to do was export the enum directly. I have submitted a PR to add the optional prefix filter portion.
At this time, exporting enums in GDScript is very cumbersome. In order for the enums' names to be visible in the editor, you must specify a set of strings to be displayed for each value. This requires a hardcoded list of strings that must be updated as the enum changes over time. Either that, or a Dictionary mapping must be made and then used in a
_get_property_list()
override in a tool script (which, in turn, necessitates an implementation of_set()
and_get()
. This can amount to as much as 20 extra lines of code + converting it to a tool script JUST to make an enum value automatically updated in the Inspector.This change would allow you to define enum exports based on an enum's identifier and using an optional string prefix to filter out string content from the keys, similar to the way the engine treats property groups.
This would then display "Fire" and "Ice" as options within the editor as it would filter out the content. If you wished to change the order, you could just change the ordering within the enum.
The text was updated successfully, but these errors were encountered: