PackedScene alternative that doesn't load the scene?

Godot Version

4.3.stable

Question

Is there a way to export a scene variable that will automatically update the reference if the scene’s file path changes (like PackedScene or any other Resource type) but that doesn’t load the scene when the Node with the exported variable is loaded?

Additional context:
For my save format, I’m saving the current area the player is in as an integer ID, and when loading a save, I want to load the corresponding scene. To do that, I need a way to keep track of which scene has which ID, so my plan was to create an Array or Dictionary of scenes indexed by their ID as an exported property of my scene manager singleton. Then, when loading a save, I’d index into that collection using the saved area ID and load the scene. If I do this with an Array of PackedScenes, though, all the scenes will get loaded as soon as the game runs, which is obviously not great, as I don’t want to load anything I don’t need. So, I could use String file paths, that way I can just use load() on the necessary scene at runtime, but the paths will break if I move or rename a scene file.

You can use UID instead. In Godot 4.5 @export_file saves that automatically but for Godot 4.3 you’ll need to do it manually.

Right click on the tscn file in the FileSystem dock and Copy UID. Paste that into the entry of your exported array or dictionary.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.