docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method AddItem

    AddItem(int, int)

    Adds a new entry of the specified InventoryItemDefinition by Hash. Returns the new (or existing) reference to the instance. Returns the new reference to the instance when the item didn't already exist in the Inventory and returns an existing reference when to the instance when the Item was already in the Inventory. Items added to the wallet Inventory must contain an attached CurrencyDetailDefinition.

    Declaration
    public override InventoryItem AddItem(int itemDefinitionHash, int quantity = 1)
    Parameters
    Type Name Description
    int itemDefinitionHash

    The Hash of the InventoryItemDefinition to set.

    int quantity

    The new quantity for the specified InventoryItemDefinition.

    Returns
    Type Description
    InventoryItem

    The new or existing instance of the InventoryItem.

    Overrides
    BaseCollection<InventoryDefinition, Inventory, InventoryItemDefinition, InventoryItem>.AddItem(int, int)
    Exceptions
    Type Condition
    InvalidOperationException
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)