In Godot 4.5 beta 6, I’ve a drag-and-drop state of affairs the place the info being moved between nodes is saved utilizing situations of a customized useful resource.
The useful resource occasion is added to a property referred to as information
inside a scene referred to as slot.tscn
and set to be distinctive. A number of slots are then added to the scene tree, and their information situations configured with totally different values, relying on what information every slot is meant to carry.
When the participant drag-and-drops from one slot to a different, the useful resource situations held by slots are swapped. To save lots of the sport state to disk, I assumed I’d:
- get every slot index (really a bit extra difficult than that however you get the gist)
- get the UID of the useful resource from its
slot.information
property
And save this utilizing a dictionary:
{
0: "...someresourceuid...",
1: "...someresourceuid...",
2: "...someresourceuid...",
}
To load the sport, I’d simply re-assign the useful resource situations as retrieved by the dictionary.
Nevertheless:
- utilizing
ResourceLoader.get_resource_uid(slot.information.resource_path)
returns -1 - utilizing
slot.information.resource_path
returns an empty string
After I save the useful resource situations to disk (which isn’t my desire because it provides yet one more step for every slot), then:
- utilizing
ResourceLoader.get_resource_uid(slot.information.resource_path)
returns a UID whereas modifying the mission, however returns -1 in an exported mission - utilizing
slot.information.resource_path
returns a path
So I suppose I may retailer all situations of slot.information
and use their paths, which is additional work, or add an extra id
property which I then need to handle myself, additionally additional work.
Is there no technique to make the most of the UIDs or different already current worth to uniquely determine useful resource situations that may work with the save technique described above?
EDIT: Noticed resource_scene_unique_id
which does appear to persist by export. Would this be one thing to look into?