Skip to main content
Folder: Packages/com.molca.core/Runtime/ReferenceSystem/

When to use

Use the reference system when you need stable, late-bound connections between objects across scenes or prefab boundaries:
  • Cross-scene references — link a step in one scene to an interaction in another without hard SerializeField references.
  • Addressable/dynamic content — resolve references after objects are loaded at runtime.
  • VR step → interaction wiringValveStep finds its ValveInteraction via SceneObjectReference rather than a direct drag-and-drop link.
Step implements IReferenceable<Step> with RefType "Step".

Typical pattern

  1. Target: add ReferenceableComponent, set unique Ref Id.
  2. Consumer: SceneObjectReference field in Inspector, then Resolve<T>() after RuntimeManager.WaitForInitialization().

Code

Prefer ResolveAsync<T>() so registration has finished; synchronous Resolve<T>() is fine once RuntimeManager.IsReady.

Troubleshooting

  • Resolve<T>() returns null: the target ReferenceableComponent may not be registered yet. Use ResolveAsync<T>() after RuntimeManager.WaitForInitialization() instead.
  • Duplicate Ref Ids: each ReferenceableComponent must have a unique RefId within its RefType. Duplicates cause the first registration to win; later ones are silently ignored.
  • Reference breaks after scene reload: ReferenceManager clears registrations on scene changes. Re-resolve references in OnEnable or Start of the new scene.

Unity Editor

Scene Object Reference Drawer

ReferenceableComponent + SceneObjectReference custom drawers