docs.unity3d.com
    Show / Hide Table of Contents

    Class PlayerInventory

    The PlayerInventory methods provide access to the current player's inventory items, and allow you to update them.

    Inheritance
    Object
    PlayerInventory
    Namespace: Unity.Services.Economy
    Syntax
    public class PlayerInventory : object

    Methods

    AddInventoryItemAsync(String, PlayerInventory.AddInventoryItemOptions)

    Adds an inventory item to the player's inventory.

    Throws a EconomyException with a reason code and explanation if the request is badly formed, unauthorized or uses a missing resource.

    Declaration
    public Task<PlayersInventoryItem> AddInventoryItemAsync(string inventoryItemId, PlayerInventory.AddInventoryItemOptions options = null)
    Parameters
    Type Name Description
    String inventoryItemId

    The item ID to add

    PlayerInventory.AddInventoryItemOptions options

    (Optional) Use to set the PlayersInventoryItem ID for the created instance and instance data.

    Returns
    Type Description
    Task<PlayersInventoryItem>

    The created player inventory item.

    Exceptions
    Type Condition
    EconomyException

    Thrown if request is unsuccessful

    DeletePlayersInventoryItemAsync(String, PlayerInventory.DeletePlayersInventoryItemOptions)

    Deletes an item in the player's inventory.

    Throws a EconomyException with a reason code and explanation if the request is badly formed, unauthorized or uses a missing resource.

    Declaration
    public Task DeletePlayersInventoryItemAsync(string playersInventoryItemId, PlayerInventory.DeletePlayersInventoryItemOptions options = null)
    Parameters
    Type Name Description
    String playersInventoryItemId

    PlayersInventoryItem ID for the created inventory item

    PlayerInventory.DeletePlayersInventoryItemOptions options

    (Optional) Use to set a write lock for optimistic concurrency

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    EconomyException

    Thrown if request is unsuccessful

    GetInventoryAsync(PlayerInventory.GetInventoryOptions)

    Gets the inventory items in the inventory of the player that is currently signed in. The players items are available on the returned object using the

    PlayersInventoryItems
    property. The results are paginated - the first set of results are initially returned, and more can be requested with the
    GetNextAsync
    method. The
    HasNext
    property indicates whether there are more results to be returned. Throws a EconomyException with a reason code and explanation if the request is badly formed, unauthorized or uses a missing resource.
    Declaration
    public Task<GetInventoryResult> GetInventoryAsync(PlayerInventory.GetInventoryOptions options = null)
    Parameters
    Type Name Description
    PlayerInventory.GetInventoryOptions options

    (Optional) Use to set request options. See GetInventoryOptions for more details.

    Returns
    Type Description
    Task<GetInventoryResult>

    A GetInventoryResult object, with properties as specified above.

    Exceptions
    Type Condition
    EconomyException

    Thrown if request is unsuccessful

    UpdatePlayersInventoryItemAsync(String, Dictionary<String, Object>, PlayerInventory.UpdatePlayersInventoryItemOptions)

    Updates the instance data of an item in the player's inventory.

    Throws a EconomyException with a reason code and explanation if the request is badly formed, unauthorized or uses a missing resource.

    Declaration
    public Task<PlayersInventoryItem> UpdatePlayersInventoryItemAsync(string playersInventoryItemId, Dictionary<string, object> instanceData, PlayerInventory.UpdatePlayersInventoryItemOptions options = null)
    Parameters
    Type Name Description
    String playersInventoryItemId

    PlayersInventoryItem ID for the created inventory item

    Dictionary<String, Object> instanceData

    Instance data

    PlayerInventory.UpdatePlayersInventoryItemOptions options

    (Optional) Use to set a write lock for optimistic concurrency

    Returns
    Type Description
    Task<PlayersInventoryItem>
    Exceptions
    Type Condition
    EconomyException

    Thrown if request is unsuccessful

    Events

    PlayersInventoryItemUpdated

    Declaration
    public event Action<string> PlayersInventoryItemUpdated
    Event Type
    Type Description
    Action<String>
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023