question

Michael Brilz avatar image
Michael Brilz asked

Check if Inventory are empty

Hello what is the code when I want to check whether the inventory is empty. I just can't do it
unity3dPlayer 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

·
Muhammad Roshaan Tariq avatar image
Muhammad Roshaan Tariq answered

Hey, please follow this link

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

Michael Brilz avatar image Michael Brilz commented ·
I tried this code but it doesn't work



        GetUserInventoryRequest getUserInventoryRequest = new GetUserInventoryRequest();
        PlayFabClientAPI.GetUserInventory(getUserInventoryRequest, OnGetUserInventory, OnPlayFabError);
    }

    private void OnPlayFabError(PlayFabError obj)
    {
        throw new NotImplementedException();
    }

    private void OnGetUserInventory(GetUserInventoryResult result)
        {

        List<ItemInstance> userInventoryList = result.Inventory;

        foreach (ItemInstance i in result.Inventory)
        { 
            
           
   
                   if(userInventoryList.Count == 0)
                     {
                SceneManager.LoadScene("IntoChoose");
                break;

            }
        }
            }

        
0 Likes 0 ·
Muhammad Roshaan Tariq avatar image Muhammad Roshaan Tariq Michael Brilz commented ·

Can you please share your ItemInstance class?

0 Likes 0 ·
Muhammad Roshaan Tariq avatar image Muhammad Roshaan Tariq Muhammad Roshaan Tariq commented ·

Also the API returns the data in JSON format which means you cannot simply assign the result to you variable

You need to use "JsonUtility.FromJSON<your-object-type>(pass-your-result-here)"

0 Likes 0 ·
Show more comments
Show more comments

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.