Godot Version
v4.6.stable.mono.official [89cea1439]
Question
I have a scene with this script attached, so I can create and fill enum array through GUI. It appears in GUI, and I can properly fill it with objects.
[ExportSubgroup("Settings")]
[Export] private Godot.Collections.Array<EnemyType> _mobs;
public override void _Ready()
{
GD.Print($"{_mobs.Count}");
}
The issue is that this throws null reference exception (_mobs is null). Which is a lie, since array exists and has elements.
If I do this:
[ExportSubgroup("Settings")]
[Export] private Godot.Collections.Array<EnemyType> _mobs = new();
public override void _Ready()
{
GD.Print($"{_mobs.Count}");
}
There are no errors, but _mobs has 0 elements. new() overrides what was set in GUI and clears the array.
There is also this approach:
[ExportSubgroup("Settings")]
[Export] private EnemyType[] _mobs;
public override void _Ready()
{
GD.Print($"{_mobs.Length}");
}
But this doesn’t even compile, since enums are not supported export members.
I have tried everything, I’m out of ideas, beside going around it and breaking a bunch of coding principles in the process.