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
  • ๐ŸŽจ What is PetClothesData?
  • ๐Ÿ“Œ Registering in GameInstance
  • ๐Ÿงฉ How to Create a New Accessory
  • ๐ŸŽจ Color Override (optional)
  • ๐Ÿง  How It Works
  • โœ… Example Usage
  1. Modifying the project

๐Ÿงข Adding a New Accessory

In the Virtual Pet Game Template, you can define clothing and appearance overrides for pets using the PetClothesData ScriptableObject. These items can be purchased, equipped, and rendered on the pet using the integrated UI and PetModel system.


๐ŸŽจ What is PetClothesData?

The PetClothesData object defines:

  • A unique item ID

  • A shop icon, localized name and description

  • Shop data like price, currency ID, and type (normal/premium)

  • A slot type (e.g., "Hat", "Glasses", "Shirt")

  • Optionally, a pet color override

When equipped, this item will be rendered on the correct part of the pet if the PetModel prefab has an associated object for the item ID in the correct slot.


๐Ÿ“Œ Registering in GameInstance

After creating the PetClothesData asset, you must add it to the GameInstance under the array petClothesData.

GameInstance.Instance.petClothesData

This is required so the item can be recognized by the shop, inventory, and equipped correctly by the player.


๐Ÿงฉ How to Create a New Accessory

  1. Rightโ€‘click in the Project panel โ†’ Create โ†’ PetCareGame โ†’ Pet Clothes Data

  2. Fill in the following fields:

    Field
    Description

    itemId

    Unique identifier, used in save/load

    itemIcon

    Display icon in shop

    itemName

    Localized name using NameTranslatedByLanguage

    itemDescription

    Localized tooltip

    currencyId

    Currency to buy this item (e.g., "GO")

    itemPrice

    Price for this item

    clothBuyType

    Normal or Premium

    overridePetColor

    If true, pet color is replaced

    overrideColor

    The new color applied when equipped

    clothSlotType

    Slot category (e.g., "Hat", "Back", "Glasses")


๐ŸŽจ Color Override (optional)

If overridePetColor is enabled, this item will change the base color of the pet when equipped. The color is restored when the item is unequipped.


๐Ÿง  How It Works

  • When a pet is spawned via GameInstance.InstantiatePetModel(), the pet loads all currently equipped items from PlayerSave.

  • For each clothSlotType, it searches the corresponding slot on the PetModel.objectsToActivate list.

  • It activates the CharacterObject whose itemId matches.

  • If overridePetColor is true, it calls PetModel.UpdateColor().


โœ… Example Usage

To equip a saved item, the system internally uses:

PlayerSave.SetSelectedClothes("Hat", "RED_CAP");

And on the PetModel, it automatically activates:

objectsToActivate โ†’ slotId: "Hat"
    โ†’ itemId: "RED_CAP" โ†’ activate associated GameObjects

You only need to ensure the item ID matches the one defined in the prefab.

Previous๐ŸŽ How to Add a New Food ItemNext๐ŸŽฎ How to Add a New Minigame

Last updated 28 days ago