References

How a stored persistent id becomes a live object again, the resolution order, and why the index is cleared with the session.

Unity NexusForge Persistence 0.2.0 Updated

A reference is a stored id, never an object#

csharp
public GameObject door;      // stored as door's persistent id
public Inventory owner;      // stored as owner's persistent id

Turning 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#

  1. The resolver you pass to UnityObjectApplier.TryRestore(...) — the most explicit option, best for tests and for scenes you control.
  2. A resolver the game injected with NexusForgePersistence.IdentifierResolver.
  3. The session's own index, which save components populate automatically with the objects they capture. NexusForgePersistence.RegisterPersistentObject adds anything else you want resolvable — a pooled object, an object created after the load, a singleton.
csharp
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#

PolicyBehaviour
ClearAndReport (default)The field is cleared and the issue is reported: the reference is gone, and you know.
KeepLiveValueThe existing value is kept, so a partially-known world stays usable.
ClearCleared silently — for fields where absence is a valid state.
FailThe batch stops; for strict modes and test scenes.

Next#

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