Godot Version
4.3.stable
Question
i’m having troubles with an exported array field not getting initialized correctly when running the game.
the issue is similar to Exported array variables getting default values on _ready(), but my Ring class is not a singleton. here is a snapshot of my “EffectRing” class, which has an exported array called “data” (currently with a setter to allow debugging):
the data is used to cycle through colors/sizes/etc. for cool effects. i normally instantiate this class and add the data elements dynamically, but it also looks good in the editor if i try to add it as an effect to a healing item/goody:
i can look at the heal-item tscn file as well and nothing looks amiss; it has the array in it. and we can also see the rings in the room where i want to put it:
but as soon as i try to play the game, the scene does not instantiate with the array. the new_value
that is passed in to the array setter is an empty array, which you can see in the debugger:
and due to this, the game logic removes the ring since it’s in an invalid state:
i have a fairly large and complex project, and if i try to start a new project and create a minimum reproducible example, it works – i can instantiate (even dynamically) a class that has an exported array. because of that, i assume it’s configuration related, but definitely been scratching my head for a bit here. because i was only doing things dynamically, i originally had the data array as unsaved property (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT), but i’ve stopped doing that and deleted the .godot folder.