References
How a stored persistent id becomes a live object again, the resolution order, and why the index is cleared with the session.
A reference is a stored id, never an object#
public GameObject door; // stored as door's persistent id
public Inventory owner; // stored as owner's persistent idTurning that id back into a live object is a decision about the running world, so it goes through a resolver rather than a lookup table buried in the framework.
Resolution order#
- The resolver you pass to
UnityObjectApplier.TryRestore(...)— the most explicit option, best for tests and for scenes you control. - A resolver the game injected with
NexusForgePersistence.IdentifierResolver. - The session's own index, which save components populate automatically with the objects they capture.
NexusForgePersistence.RegisterPersistentObjectadds anything else you want resolvable — a pooled object, an object created after the load, a singleton.
class="tok-com">// Anything the framework does not see during capture is registered by you.
NexusForgePersistence.RegisterPersistentObject(pooledEnemy);Why the index is session-owned#
The index is cleared with the session, so it can never resolve an identity to last session's object. That one property removes a whole class of bug where a save silently reattaches to a destroyed or unrelated instance.
The index also counts claimants per identity, which is what lets the duplicate-identity policy report an ambiguity instead of picking one silently. See Restore.
When a reference cannot be resolved#
| Policy | Behaviour |
|---|---|
ClearAndReport (default) | The field is cleared and the issue is reported: the reference is gone, and you know. |
KeepLiveValue | The existing value is kept, so a partially-known world stays usable. |
Clear | Cleared silently — for fields where absence is a valid state. |
Fail | The batch stops; for strict modes and test scenes. |
Next#
- Prefabs — when the object does not exist yet.
- Persistent IDs — where the ids come from.
- Restore — every policy in one table.
Something wrong on this page? Every page here describes behaviour that is checked in the repository. If a page and the package disagree, the package wins.
Report a documentation problem · Frequently asked questions · Troubleshooting