RevFramework – Sample Scene: 04_Currency_UIBars¶
Goal¶
Teach the currency UI update loop:
Mutate balance through ICurrencyService → service raises OnWalletChanged → bound UI bars update.
What This Scene Demonstrates¶
This scene shows that currency UI is a view over service-owned data.
The flow is:
Owner → ICurrencyService → Credit / Debit / SetBalance → CurOpResult → OnWalletChanged → UI bar refresh
- The service owns the wallet data
- The panel mutates balances through public service calls
- Bars bind to the same owner and
CurrencyDefinition - Bars update from
ICurrencyService.OnWalletChanged - The panel does not directly refresh the bars
- UGUI and UI Toolkit bars can show the same wallet state
CurrencyBarTMPis available, but not used in this demo to avoid forcing TextMeshPro into the scene
Bars are views.
The service result is truth.
What To Look For¶
Use the CurrencyUIBarsPanel as a public-API nudger for testing UI wiring.
-
Owner / Service
-
Owner is the wallet being mutated
- Service shows the resolved
ICurrencyServicestack -
If either is missing, fix setup before debugging bars
-
Bars
-
The scene shows Canvas/UGUI and UI Toolkit bars
- Supported bar types are
CurrencyBar,CurrencyBarTMP, andCurrencyBarUITK -
Bar detection only checks that bars exist; it does not verify owner/currency binding
-
Selected Currency
-
Selects the active
CurrencyDefinition - Resolves the active
CurrencyId -
Shows the live service balance for the selected owner/currency
-
Nudger
-
Delta
+callsCredit - Delta
-callsDebit - Set
ApplycallsSetBalance -
Small nudge buttons are shortcuts for common test values
-
Notes
-
If the result succeeds and the live balance changes, the mutation path is working
- If the bar does not move, check bar binding and event subscription next
Sample Scope¶
This scene covers:
- Driving wallet changes through
ICurrencyService - Event-driven UI updates through
OnWalletChanged - UGUI/Canvas bar display
- UI Toolkit bar display
- Optional TextMeshPro bar support as a framework component
- Live verification using the selected owner and currency
- Failure reporting through
CurOpResult
This scene does NOT cover:
- Building a full game HUD
- Styling every UI variant
- TextMeshPro package setup
- UI Toolkit authoring in depth
- Runtime spawning workflows in depth
- Multiplayer replication or networking
Those are project-level UI concerns.
Authority Note¶
This scene may include a permissive sample authority setup so it runs without additional configuration.
Networking Reminder¶
RevFramework does not include networking.
For multiplayer projects, currency mutations must be validated and executed through your own authority and networking layer. UI bars should reflect server-approved wallet changes, not untrusted client-side guesses.
How To Use¶
- Enter Play Mode.
- Toggle the
CurrencyUIBarsPanelwithF8. -
Confirm the top bindings:
-
Owner is assigned
ICurrencyServiceis resolved-
Check the Bars section:
-
Confirm at least one UI bar exists if you want visual updates
- Confirm bars are bound to the same owner and currency you are testing
- Select a currency.
- Read the live service balance.
-
Use the Nudger:
-
Press
+to credit the selected currency - Press
-to debit the selected currency - Press
Applyto set an absolute balance - Use small nudge buttons for quick feedback
- Confirm the live balance updates.
- Confirm matching UI bars update from the same wallet change.
Failure Behaviour¶
Failures are shown through dependency messages or the returned CurOpResult.
Common causes:
-
Play Mode required
-
The panel nudges balances and expects bars to react to runtime wallet events
-
Fix: enter Play Mode
-
Service missing
-
No
ICurrencyServicewas resolved -
Fix: add
SceneCurrencyService, addCurrencyServiceBootstrap, or publish a composed service -
Owner missing
-
No wallet owner is selected
-
Fix: assign an owner or tag the player GameObject as
Player -
No currencies bound
-
No
CurrencyDefinitionassets are available -
Fix: assign currencies in the Inspector or provide a
CurrencySet -
Invalid CurrencyId
-
The selected
CurrencyDefinitionhas an invalid Id -
Fix: correct the CurrencyDefinition asset
-
Invalid amount
-
Credit/Debit requires a delta greater than zero
-
Fix: enter a positive delta value
-
Mutation failed
-
The service rejected the operation
-
Fix: check balance, caps/policy, authority, escrow, and service composition before debugging the UI bar
-
Mutation succeeds but bar does not update
-
The balance path worked, but the view did not react
- Fix: check the bar owner, currency definition, service reference, and
OnWalletChangedsubscription
Behind The Scenes¶
The panel uses real Currency APIs:
-
CurrencyResolve.ServiceFrom -
resolves the active
ICurrencyService -
ICurrencyService -
GetBalance CreditDebitSetBalance-
OnWalletChanged -
CurOpResult -
Success Code-
Message -
UI bar components:
-
CurrencyBar CurrencyBarUITKCurrencyBarTMPwhen TextMeshPro is available
The panel only mutates balances.
The bars listen to the service and redraw themselves.
No bar is the source of truth.
Demo-Only Assets¶
This scene may include demo-only scripts and UI Toolkit assets for layout, spacing, and presentation.
These assets support the sample scene only. They are not required by the Currency system and can be replaced or removed with the scene.
The Currency system itself only requires service data and event-driven binding.
Key Takeaway¶
The service owns the data.
The bars are views bound to owner and currency.
The panel is just a public-API driver used to prove the wiring works.