question

Yichen Wang avatar image
Yichen Wang asked

How can I retrieve and change the custom data of an item? Please give an example.

Hi, I am trying to make a system where I can upgrade an item. I looked at a lot of posts and realized that using custom data of a item is the way to go. The documentation isn't very helpful. Can someone please give me an example of what I need to use. Do I need to add something to cloudscript? Also, one last question. I put the custom data of an item in the catalog, but a player buy the item, does the custom data gets copied and pasted to the same item the user bought. So basically, the custom data on the item are

  • level = 1
  • health = 100
  • isSelectedAndEquipped = false

So will the same item the player bought have the same custom data like the one above. Thank you!

unity3ddocumentation
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

The Custom Data in Catalog item and Player Inventory is separate, and when an item is granted to a player, the Custom Data won’t be copied automatically. If you are about to refer those predefined data, you may need to store the complete catalog data locally for late use.

To update Custom Data of an item instance in player inventory, you may implement a cloud script function, where UpdateUserInventoryItemCustomData API will be called. You may either define 3 KVP entries in Data property of the request or define a JSON object and stringify it in Cloud Script as single KVP entry.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.