Question
If I have multiple instances of a scene in the SceneTree, I want to be able to uniquely identify which is which, in a way that is consistent even when the game is restarted or the scene is reloaded.
Example
For example, say my game has a player you can move around, and two rooms. There is a door that allows you to go between the rooms. The rooms are different scenes, when you go to the other room, it is loaded into memory and the previous one is freed.
In each room is two treasure chests, and I need to remember which ones the player has opened already, so that when they go back to a room, I can render the previously opened chests as open.
How can I store which treasure chests are already opened?
My current solution is to export a variable on the treasure chest representing a unique id, and typing something random in that field on the editor. In this way, I can save reference to the specific instance of the chest that should be open or not in a Singleton script. But I’m wondering if there’s built-in way to do this so I don’t need to type anything manually for the id.