question

Kyohei Ichikawa avatar image
Kyohei Ichikawa asked

I want to get the instance ID from the item name.

I want to get the instance ID from the name of the item in the player's inventory.

How can I do this?

Player Dataunity3dPlayer Inventory
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

·
Sarah Zhang avatar image
Sarah Zhang answered

According to the question tag you set, your development platform is Unity3D, is it right? If so, you can use the following code to get the corresponding item instance Id according to the item’s display name. For more questions about C# syntax, please check the C#documentations.

   private void OnGetSuccess(GetUserInventoryResult result)
    {
        foreach (var item in result.Inventory)
        {
            if (item.DisplayName == "[Your item display name]")
            {
                Debug.Log(item.ItemInstanceId);
            }
        }    
    }
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.