💰 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 DataSet 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
⚠️
coinIDmust be unique across all currencies
2. Add to the GameInstance
Open the
GameInstanceComponent in Home SceneLocate the
currencyDataarrayAdd your new
CurrencyDataasset to this list
public CurrencyData[] currencyData;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
CurrencyDisplaycomponent to a UI element (e.g. under your HUD)Set the
currencyIDto match your new coinAssign the
TextMeshProUGUIandImagereferences
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
Xseconds/minutes/hoursRecharge logic is handled by
RechargeablesManagerand 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