Skip to content

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 → CurOpResultOnWalletChanged → 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
  • CurrencyBarTMP is 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 ICurrencyService stack
  • 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, and CurrencyBarUITK
  • 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 + calls Credit

  • Delta - calls Debit
  • Set Apply calls SetBalance
  • 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

  1. Enter Play Mode.
  2. Toggle the CurrencyUIBarsPanel with F8.
  3. Confirm the top bindings:

  4. Owner is assigned

  5. ICurrencyService is resolved
  6. Check the Bars section:

  7. Confirm at least one UI bar exists if you want visual updates

  8. Confirm bars are bound to the same owner and currency you are testing
  9. Select a currency.
  10. Read the live service balance.
  11. Use the Nudger:

  12. Press + to credit the selected currency

  13. Press - to debit the selected currency
  14. Press Apply to set an absolute balance
  15. Use small nudge buttons for quick feedback
  16. Confirm the live balance updates.
  17. 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 ICurrencyService was resolved

  • Fix: add SceneCurrencyService, add CurrencyServiceBootstrap, 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 CurrencyDefinition assets are available

  • Fix: assign currencies in the Inspector or provide a CurrencySet

  • Invalid CurrencyId

  • The selected CurrencyDefinition has 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 OnWalletChanged subscription

Behind The Scenes

The panel uses real Currency APIs:

  • CurrencyResolve.ServiceFrom

  • resolves the active ICurrencyService

  • ICurrencyService

  • GetBalance

  • Credit
  • Debit
  • SetBalance
  • OnWalletChanged

  • CurOpResult

  • Success

  • Code
  • Message

  • UI bar components:

  • CurrencyBar

  • CurrencyBarUITK
  • CurrencyBarTMP when 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.