๐งข 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
?
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
.
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
Rightโclick in the Project panel โ Create โ PetCareGame โ Pet Clothes Data
Fill in the following fields:
FieldDescriptionitemId
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 fromPlayerSave
.For each
clothSlotType
, it searches the corresponding slot on thePetModel.objectsToActivate
list.It activates the
CharacterObject
whoseitemId
matches.If
overridePetColor
is true, it callsPetModel.UpdateColor()
.
โ
Example Usage
To equip a saved item, the system internally uses:
And on the PetModel
, it automatically activates:
You only need to ensure the item ID matches the one defined in the prefab.
Last updated