Replies: 1 comment
-
I have a similar issue, and have been thinking about how I would like a solution to look. For one, I would disallow the As for how the syntax would look, I would say one of these would be a nice way of doing it: enum MyEnum[StringName] {
VALUE_1, # = &"VALUE_1"
VALUE_2 = &"value_2",
VALUE_3, # = &"VALUE_3"
} enum MyEnum -> StringName {
VALUE_1, # = &"VALUE_1"
VALUE_2 = &"value_2",
VALUE_3, # = &"VALUE_3"
} In both examples above, EDIT: However, since only the types str_enum MyEnum {
VALUE_1, # = &"VALUE_1"
VALUE_2 = &"value_2",
VALUE_3, # = &"VALUE_3"
} Instead? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If I have an enum, and I export it for use in the inspector, then whatever value I choose is saved to that scene/resouce as the integer value of that enum entry. This has a benefit, in that if I decide to rename the enum constant later, it still points to the same thing... but, it has the downside, that if I want to add new entries in the middle of the enum, it breaks all scenes/resources that reference it, which seems far worse.
It would be nice to have some form of annotation or setting to make such an enum save as a string to the resource, so that adding in the middle of the enum won't break the references. (Simply saving the string to file, but converting back to the value on loading, giving a warning if the value is not found or etc).
It could also, either instead or in addition, be nice to have the ability to have a
String
variable that uses the options in the inspector from an enum (as, well,@export_enum()
, but automatically using the values of an enum type, rather than listing them out manually).Both of these ideas should also extend to the keys/values of typed dictionaries and values of typed arrays; which, for (2), would solve #11337 .
Beta Was this translation helpful? Give feedback.
All reactions