Virtual Pet Game Template
  • VIRTUAL PET GAME TEMPLATE
  • Getting Started
    • ๐ŸŽฏ Project Setup Guide
    • ๐Ÿงฉ Home Scene Overview
    • ๐Ÿ—บ๏ธ UI Main Menu
    • ๐Ÿ—บ๏ธ LoadingManager
    • ๐Ÿ—บ๏ธ GameInstance
    • ๐Ÿ—บ๏ธ ToolsManager
    • ๐Ÿ—บ๏ธ AudioManager
    • ๐Ÿ—บ๏ธ LanguageManager
    • ๐Ÿ—บ๏ธ MonetizationManager
    • ๐Ÿ—บ๏ธ PlayerSave
  • Modifying the project
    • ๐Ÿพ How to Add a New Pet
    • ๐Ÿ“œHow Add a New Pet Rules
    • ๐Ÿ’ฐ How to Add a New Currency
    • ๐ŸŽ How to Add a New Food Item
    • ๐Ÿงข Adding a New Accessory
    • ๐ŸŽฎ How to Add a New Minigame
  • Modifying Minigames
    • ๐ŸŒค๏ธ Minigame "Jump Sky"
    • ๐Ÿ” Minigame "Food Flicker"
    • ๐Ÿฆ Minigame โ€œFlappyโ€
    • ๐Ÿ’Ž Minigame โ€œGem Hunterโ€
Powered by GitBook
On this page
  • ๐Ÿงพ Step-by-Step Instructions
  • โšก Rechargeable Currencies
  • โœ… Summary
  1. Modifying the project

๐Ÿ’ฐ 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 UI

    • initialAmount: 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 Scene

  • Locate the currencyData array

  • Add your new CurrencyData asset 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 CurrencyDisplay component to a UI element (e.g. under your HUD)

  • Set the currencyID to match your new coin

  • Assign the TextMeshProUGUI and Image references

currencyDisplay.currencyID = "gems";

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:

// Add coins
PlayerSave.AddCoin("gems", 10);

// Remove coins
PlayerSave.RemoveCoin("gems", 5);

// Get current amount
int current = PlayerSave.GetCoin("gems");

โšก Rechargeable Currencies

If isRechargeableCurrency is enabled:

  • The system will automatically recharge the coin every X seconds/minutes/hours

  • Recharge logic is handled by RechargeablesManager and UI updated by CurrencyDisplay

You can also specify:

  • Offline recharge support

  • Max limit enforcement

  • Can exceed max toggle for gifts or purchases


โœ… Summary

Feature
Supported

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.

Previous๐Ÿ“œHow Add a New Pet RulesNext๐ŸŽ How to Add a New Food Item

Last updated 28 days ago