Godot Version
4.4
Question
I am trying to modularize my code, and make creating new levels as easy as possible. I have reduced all the code down to generic code that requires a handful of parameters, and created a new Custom Resource type (Level_Resource) to contain that data. (2 typed dictionaries) I created a new resource of this type in the inspector, populated both dictionaries with 2 entries each, and saved this resource to disk (Level1.tres). Inspecting the .tres file shows that it is correct.
I created my new Level scene, attached the Resource in the inspector, and saved the Level1.tscn. Inspecting the property in the inspector at runtime shows the expected data in the dictionaries, loaded from the file.
But when I run the game, and instantiate Level1.tscn, the dictionaries in the resource object are null. Hovering the property in my code window (with the game paused) shows the 2 dictionaries instantiated, but empty (Current Value: { } ) The “Stack Variables” panel shows the same (although the Object ID for the Level_Resource object are different in these two scenarios). But if I navigate the Remote Tree down to the Level1 Node, the Level_Resource object THERE is properly populated with 2 dictionaries with items in them (size 2).
Filter stack object inspector:
Remote tree object inspector:
I’m not sure how I have three apparently different Level_Resource objects, or why 2 of them are empty, or how I can access the values that the tree shows me are loaded.
(Edited to add: with the values from the resource file hard coded into my code, it works fine. I have isolated the problem to the resource integration not working right for me for some reason. Also, I have done a similar thing with my items since writing this, because I know this is the design pattern I want to use, and it weirdly works for the items just fine. I have clearly missed a step with the level part, but I don’t know what it could be. Unless the dictionaries specifically are my problem?)