Skip to content

Exported flag enum default initializer is ignored — breaks ability to set “all flags off” #112845

@TheThrym

Description

@TheThrym

Tested versions

Reproducible in:

  • v4.4.stable.mono.official [4c311cb]
  • v4.5.1.stable.mono.official [f62fdbd]
  • v4.6.dev4.mono.official [bd2ca13]

System information

Godot v4.5.1.stable.mono - Windows 11 (build 26200) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.8157) - AMD Ryzen 7 3700X 8-Core Processor (16 threads) - 31.92 GiB memory

Issue description

Exported flag enum properties appear correctly in the Inspector, but default values assigned via auto-property initializer are ignored.
The Inspector displays all checkboxes as unchecked.

This causes a functional problem:
The true “all-off” state becomes impossible to select because the Inspector already shows it due to the incorrect initialization.

Example:

[Export]
public MyFlags Mode { get; set; } =
    MyFlags.A | MyFlags.D;

Expected:
The Inspector should show “A” and “D” as checked according to the default.

Actual:
All checkboxes are shown unchecked, ignoring the default value.

Steps to reproduce

  • Create any Node script in C# using a [Flags] enum.
  • Add an exported auto-property with a default initializer combining multiple flags:
 [Export]
public MyFlags Mode { get; set; } = MyFlags.A | MyFlags.D;
  • Attach the script to a node.
  • Open the node in the Godot Editor’s Inspector.

Minimal reproduction project (MRP)

Test.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions