Skip to content

💰 Currency / UnityIntegration

🎯 Purpose

The UnityIntegration layer provides Unity-specific runtime components that connect the Currency system to a scene.

These components handle scene hosting, MonoBehaviour lifecycle, and Unity-driven updates.

They do not define currency behaviour or composition.


⚠️ Important Notes

  • This layer is Unity-specific
  • It provides runtime hosting, not behaviour
  • Composition is handled by the Bootstrap layer
  • Behaviour is defined by composed services

🧩 What Lives Here

SceneCurrencyService

  • Default in-memory wallet implementation
  • Stores balances per GameObject
  • Implements ICurrencyService
  • Emits CurrencyDelta events

Used as the base service for composed stacks.


CurrencyEscrowExpiryPump

  • Periodically calls ICurrencyEscrow.ExpireStale() when available
  • Used when escrow and expiry behaviour are required

CurrencyJsonSave

  • Scene-level helper for saving and restoring wallets to JSON
  • Uses CurrencyPersistence for capture and restore

This is a convenience MonoBehaviour and not the persistence contract.


🧠 Usage Guidance

Mental model

  • UnityIntegration hosts the system in a Unity scene
  • It does not define behaviour
  • It provides entry points for runtime usage

SceneCurrencyService
CurrencyServiceBootstrap

Access the service via:

var svc = CurrencyResolve.ServiceFrom(this);

When to use

Use this layer when:

  • Running Currency inside Unity scenes
  • Using MonoBehaviour-based workflows

When to replace

Consider replacing this layer when:

  • Not using Unity scene hosting
  • Running in a different runtime environment

🚫 Internal Use Only

This folder provides runtime hosting only.

Do not:

  • Add gameplay logic here
  • Treat this as an extension surface
  • Depend on concrete implementations in gameplay code

🧹 Safe to Remove

This folder may be replaced if a custom runtime host is provided.

Removing it requires supplying an alternative ICurrencyService host.


  • Abstractions — contracts
  • Internal — behaviour implementation
  • Bootstrap — composition and publishing
  • PublicAPI — supported usage surface