๐ฐ How to Add a New Currency
This guide explains how to create and integrate a new in-game currency using the CurrencyData system provided by the template.
๐งพ Step-by-Step Instructions
1. Create the Currency Asset
Right-click in the Project window โ
Create
โPetCareGame
โCurrency Data
Set the following fields:
coinName
: Display name (used in UI only)coinID
: Unique identifier (e.g."gems"
,"stars"
)icon
: Sprite shown in UIinitialAmount
: Starting value for new players(Optional) Configure limits and recharge options as needed
โ ๏ธ
coinID
must be unique across all currencies
2. Add to the GameInstance
Open the
GameInstance
Component in Home SceneLocate the
currencyData
arrayAdd your new
CurrencyData
asset to this list
This allows the system to initialize and track your new currency globally.
3. Display Currency in the UI
To show the value of your currency in the interface:
Add a
CurrencyDisplay
component to a UI element (e.g. under your HUD)Set the
currencyID
to match your new coinAssign the
TextMeshProUGUI
andImage
references
If your currency is rechargeable, enable the toggle and link the recharge UI fields.
4. Modify Currency Values
You can use the following functions to manipulate player currency:
โก Rechargeable Currencies
If isRechargeableCurrency
is enabled:
The system will automatically recharge the coin every
X
seconds/minutes/hoursRecharge logic is handled by
RechargeablesManager
and UI updated byCurrencyDisplay
You can also specify:
Offline recharge support
Max limit enforcement
Can exceed max toggle for gifts or purchases
โ
Summary
Multiple currencies
โ
Recharge over time
โ
Per-currency icon
โ
UI auto-display
โ
Offline recharge
โ
Max limits per currency
โ
This system is fully modular and supports coins, gems, stamina, energy, and other economy models.
Last updated