💰 Currency / Editor API¶
🎯 Purpose¶
The Editor API provides a minimal, editor-only surface for inspectors, wizards, teachable panels, and diagnostic tools to interact with Currency without using internal implementation details.
This assembly is editor-only and is not included in runtime builds.
⚠️ Important Notes¶
- This API is editor-only and excluded from player builds
- It does not resolve or compose services
- Tooling should resolve services via
CurrencyResolve.ServiceFrom(...) - Runtime rules (caps, authority, escrow, idempotency) still apply to operations
- Internal decorator types are not exposed
🧩 What Lives Here¶
CurrencyEditorApi¶
Provides editor-friendly helpers for resolving definitions and batching operations.
ResolveSet¶
Convenience wrapper around CurrencySetLocator.Resolve().
public static CurrencySet ResolveSet();
Resolution order:
- Scene binder (
CurrencySetBinder) - First binder in scene (includes inactive)
- Resources fallback (
CurrencySet_Default)
Used to obtain designer-authored currency definitions in editor tools.
BeginBatch¶
Begins a temporary batch scope for a provided ICurrencyService.
public static CurrencyBatching.CurrencyBatchHandle BeginBatch(ICurrencyService svc);
- Collapses multiple mutations into a single batch event when supported
- Returns a disposable scope that controls lifecycle
The batch wraps the exact service instance provided. All composed decorators continue to apply.
CurrencyBatchHandle¶
Represents a disposable batch scope returned from batching operations.
Refer to CurrencyBatching for full behaviour.
🧠 Usage Guidance¶
Resolve definitions in editor tools¶
#if UNITY_EDITOR
var set = CurrencyEditorApi.ResolveSet();
if (set)
Debug.Log($"Loaded {set.All.Count} currencies.");
#endif
Perform batched editor operations¶
#if UNITY_EDITOR
var svc = CurrencyResolve.ServiceFrom(this);
using var batch = CurrencyEditorApi.BeginBatch(svc);
// Perform multiple mutations
batch.Emit();
#endif
🧪 Diagnostics¶
- Missing definitions usually indicates no
CurrencySetBinderin the scene - Repeated UI refreshes may indicate batching is not used
🚫 Not for Production Use¶
This API is not available in runtime builds and should not be used in gameplay code.
🧹 Safe to Remove¶
This folder may be removed if no editor tooling relies on Currency helpers.
Removing it does not affect runtime behaviour.
🔗 Related Documentation¶
- Definitions —
CurrencySet,CurrencyDefinition - Core —
CurrencyBatching,CurrencyResolve,CurrencyFactories - Teaching Panels — editor tooling overlays
- Persistence — snapshot utilities for editor workflows