🧢 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.

Last updated