Does Godot preserve internal resource IDs when restoring a project backup and re‑importing missing .import files?
0 reputation · 24 Aug 2020, 22:04 UTC
0 reputation · 24 Aug 2020, 22:04 UTC
When a Godot project backup is restored and the editor regenerates missing .import files, the internal resource IDs (RIDs) assigned to assets may change. This poses a risk for saved‑game data or serialization that relies on those IDs remaining constant across sessions. While Godot 4.x attempts to keep IDs more stable, the documentation does not explicitly state whether IDs are deterministic after a backup restore, and the behavior can vary with import preset changes or engine version upgrades.
What guarantees, if any, does Godot provide about RID consistency after a backup restoration? Does the import system preserve IDs when .import files are recreated from the same source assets? How do Godot 3.x and 4.x differ in this regard, and under what conditions might IDs diverge?
35275 reputation · 25 Aug 2020, 02:42 UTC
No — and more importantly, the premise needs correcting. Godot's internal resource IDs (RIDs, as returned by Resource.get_rid()) are runtime object handles assigned fresh each time the engine loads a resource. They are not derived from your source assets or import settings, and they are never stable across editor or game sessions, regardless of whether you restore a backup, re-import assets, or change nothing at all. A backup restore and .import regeneration is therefore not the actual risk: RIDs were never safe to serialize in the first place.
uid:// paths you see in scene and script files), which is designed to be a persistent identifier for resources on disk. UIDs are stored alongside the project and survive re-imports and backup restores as long as the files carrying them are part of the backup.res://...) remain the most portable stable reference, provided files are not moved or renamed.If saved-game data broke after a restore, the cause was almost certainly that raw RIDs (or instance IDs) were written into the save file. Those values were already invalid the moment the original session ended; the backup restore merely made the failure visible. Changes to import presets or engine versions can alter imported resource content, but that is a different issue from RID stability.
res:// path or, on Godot 4.x, their uid:// path (ResourceUID.id_to_text() / ResourceLoader.load() with a UID).get_rid(), get_instance_id(), or similar runtime values.Exact UID behavior across engine upgrades and edge cases (e.g., restoring a backup that omits the project's UID cache) is version-dependent; check the documentation for your specific Godot version. You can confirm the core point quickly: print Resource.get_rid() for a loaded resource, restart the editor without changing anything, and print it again — the values will differ even with no backup or re-import involved.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.