question

Jerry avatar image
Jerry asked

Read/write Custom data inventory items in unity

Hi,

So for the past 12 hours I've been trying to access the custom data values on the items in a specific player from my server. The purpose is to read and write to this custom data with the unity app. I'm been able to get pretty much every other form of info from a certain player. But the custom data is always null I've tried json to convert it into a string but still it returns null. Is there perhaps an example for doing this if its even possible to do it outside the game manager. I'm also posting on my phone so I'm unable to post my code. Any help would be appreciated.

Player InventoryCharacter Data
1 comment
10 |1200

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

Jerry avatar image Jerry commented ·

I think i found a solution that i will post here once i'm done with it for the others out there who aren't really good with code, and doesn't understand PlayFab all the way.

1 Like 1 ·

1 Answer

·
Jerry avatar image
Jerry answered

OK,

So in Unity you might want to create a new user and have their inventory items set up for them when the game is launched for the first time.

to add these items to the players inventory you could do it from a server,client or cloud script(which ever you choose is up to you,and the method be it via granting, or purchasing(i would suggest granting via cloud script)

once you have that working you'll notice that you cant access the item instance custom data, but when you view the data via the game manager you can see it.

the reason is that when you click the item it takes you to catalog of items(this is the place where you created the items)

to view the custom data for each item click the show custom data button which is the blue (normally white)

when giving the items they don't get sent with custom data you put catalog for some reason, there must be a option that i over looked which will allow this when its being created.

but because each item in a players inventory has a unique id you can now update each item to have different values which would probably be the end objective cause each player will need different level items for example.

here is a few posts that talk about how what type of granting will affect the custom data

Here

and here for limits on the number of values a catalog can have and the number of values an item in a players inventory can have.


capture.png (22.6 KiB)
2 comments
10 |1200

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

Jerry avatar image Jerry commented ·

About Item Data

Note that individual item instances only store the following information:

  • Item ID
  • Display name
  • Item class
  • Catalog version
  • Purchase date
  • Purchase currency
  • Purchase price

All other item information (such as tags, description, or custom data) is only stored on the root catalog item.

so this means you just need to update the customs data with the ones that are used in the catalog after adding those items to the players inventory.

0 Likes 0 ·
Tuomas Erikoinen avatar image Tuomas Erikoinen commented ·

Ah, thank you very much! I was banging my head on this just because I didn't realize that by clicking the link it takes me to the catalog page and not to the item instance itself.

0 Likes 0 ·

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.