-
-
Notifications
You must be signed in to change notification settings - Fork 20.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exported enum variable defaults to 0 even if first enum int value is set to non-0, when using c# #90987
Comments
In C#, an enum's default will always be the type's default, so this is expected behavior. //enum SomeEnum { One = 1, Two, Three }
SomeEnum someEnum = default;
GD.Print(someEnum); // 0 If you want it to display a different default in the editor you can do: [Export] SomeEnum _testValue = SomeEnum.Two; |
i still think itd be better for the editor to just do that automatically, makes it a bit confusing/annoying if someone isnt aware of it |
What and how should it pick though? The first value isn't the one picked by default otherwise, for example what should be done with:
Should it be defaulted to There's a warning in GDScript recently added, maybe something similar can be done here |
yeah warning seems better for this |
As stated above, this is simply how enum types work in C#. It is already possible to enforce the existence of a zero value with Footnotes |
i noticed just now that on animatedsprite2d's, the animation will sometimes be set to "default" instead of any of the animations, so perhaps if theres no 0-value in an enum it can be shown as "default" in the editor instead? |
Tested versions
4.2.stable
System information
Godot v4.2.1.stable.mono - Arch Linux #1 SMP PREEMPT_DYNAMIC Thu, 11 Apr 2024 01:47:33 +0000 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (nvidia; 550.67) - AMD Ryzen 5 7600X 6-Core Processor (12 Threads)
Issue description
having an exported enum variable that uses an enum with a first value that isnt 0, e.g.
enum SomeEnum { One = 1, Two, Three }
, doesnt default to 1 when the export var is unchanged in the editorif you click on another value and then back to the first one, it works as expected but shows an icon to revert back to the default
Steps to reproduce
refer to MRP
Minimal reproduction project (MRP)
enum-mrp.zip
The text was updated successfully, but these errors were encountered: