Skip to Content
Unity integrationWiring the host

Wiring the host

UnityGnosisEngine component

Add UnityGnosisEngine to a scene object that should live for the whole session (often a bootstrap / systems object).

  1. Service entries — For each engine service your build registers, add a row:

    • serviceId must match the service’s Id (e.g. UserInterface, Money).
    • lifetime Permanent vs Ephemeral must match the C# service’s GnosisLifetime.
    • Adapter bindingNone, scene reference (UnityGnosisAdapter in hierarchy), or runtime prefab (spawned when the service binds).
  2. UnityAssetRegistry — Assign your registry asset so ids in data resolve to Unity objects.

  3. Run flow — Your menus / run coordinator should call the host’s public APIs to start, pause, resume, end runs (exact method names live on UnityGnosisEngine; they orchestrate ephemeral service lifetime and save hooks).

GnosisEngineBehaviour

For arbitrary MonoBehaviours that need the engine, inherit GnosisEngineBehaviour instead of MonoBehaviour:

  • Resolves UnityGnosisEngine.Instance (or FindObjectOfType fallback).
  • Retries until the underlying GnosisEngine exists, then calls OnEngineReady() once.
  • Provides GetAdapter<T>(), GetServiceById, etc.

Use this when a scene object must react to services without manual null checks everywhere.

Static instance

UnityGnosisEngine.Instance is set by the host—prefer dependency flow through explicit references or GnosisEngineBehaviour in new code; static access is convenient but harder to test.

Next: Adapters.

Last updated on