Description
Your Godot version:
v4.2.1.stable.mono.official [b09f793f5]
Issue description:
I have a C# enum and I'm trying to enable using it as a bitset, where some Node script can have 0 or more values of this enum set. I'm aiming to avoid having to fiddle around with ints if possible.
The first point of confusion comes from the first code snippet, which contains this at the end:
[Export]
public SpellElements MySpellElements { get; set; }
This...doesn't appear to work or do anything. SpellElements
isn't defined as a type anywhere else in the document.
Secondly, with this block:
// Set any of the given flags from the editor.
[Export(PropertyHint.Flags, "Fire,Water,Earth,Wind")]
public int SpellElements { get; set; } = 0;
it's unclear how this variable's declaration is connected with the enum created earlier. Probably because...it's not! Right? The flags in this type are duplicated by the enum and happen to be in the same order, which is required for it to "work".
Lastly, there's no explanation of how to use the flags. The section feels a bit incomplete, kind of "and then what?" I believe I need to use bit manipulation here? Something like ((MyEnum)SpellElements).HasFlag(MyEnum.Fire)
? I'm not even sure I can cast an int to an enum, I'm just kinda guessing.
There's also this in the same section:
[Export(PropertyHint.Layers2DPhysics)]
public uint Layers2DPhysics { get; set; }
which doesn't seem relevant to bit flags, even if they're technically implemented as bit flags.
URL to the documentation page:
If you know how to fix the issue you are reporting please
consider opening a pull request. We provide a tutorial on
using git here: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html,
writing documentation at https://docs.godotengine.org/en/stable/community/contributing/docs_writing_guidelines.html
and contributing to the class reference here: https://docs.godotengine.org/en/stable/community/contributing/updating_the_class_reference.html