Currency / UI¶
Purpose¶
The UI layer provides components for displaying wallet balances across Unity UI systems.
These components are presentational only.
Important Notes¶
- UI does not modify currency state
- UI does not own wallet logic
- Updates are driven by
ICurrencyService.OnWalletChanged - Behaviour depends on service resolution and composition
What Lives Here¶
CurrencyBar (UGUI)¶
- Uses
UnityEngine.UI.Textand optionalImage - Displays balance for a bound owner and currency
CurrencyBarTMP¶
- TextMeshPro variant
- Optional auto-rebind behaviour
- Compiled only when TextMeshPro is available, which on Unity 6 is always — TMP ships inside the built-in
com.unity.uguimodule, so there is nothing to install. Assign the label and amount fields toTextMeshProUGUIcomponents. If you have never imported TMP Essential Resources into the project (Window ▸ TextMeshPro ▸ Import TMP Essential Resources), do that first or your text components will have no font asset to draw with.
CurrencyBarUITK¶
- UI Toolkit variant
- Uses
UIDocumentand query-based binding
Usage Guidance¶
Shared behaviour¶
All components:
- Bind to an owner and
CurrencyDefinition - Resolve the service via
CurrencyResolve - Subscribe to wallet change events
- Update when relevant changes occur
- Display
0when unavailable - Rebind when service changes
Usage¶
- Create
CurrencyDefinitionassets - Add a UI component
- Assign owner and currency
- Configure UI references
Refresh API¶
bar.RefreshNow();
bar.SetOwner(newOwner);
Diagnostics¶
- No updates may indicate missing service or binding
- Incorrect values may indicate mismatched owner or currency
Not for Production Use¶
These components are reference UI implementations and may be replaced by project-specific UI
Safe to Remove¶
This folder may be removed if custom UI is used.
Currency runtime logic does not depend on UI.
Related Documentation¶
- Core — service resolution and events
- Decorators — batch and audit events
- Persistence — restore flows
- Samples — UI examples