docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class InventoryManager

    Manages all Inventories. Can subscribe to events relevant to Inventories and create and remove them here. InventoryManager also owns the main and wallet Inventories, as well as all other Inventories of InventoryItems. The InventoryManager can create Inventories from InventoryDefinitions or default Inventories as needed.

    Inheritance
    object
    InventoryManager
    Namespace: UnityEngine.GameFoundation
    Assembly: solution.dll
    Syntax
    public static class InventoryManager

    Properties

    Name Description
    IsInitialized

    Returns the current initialization state of the InventoryManager.

    catalog

    This is the InventoryCatalog the InventoryManager uses.

    main

    This is a reference to the "main" Inventory for the InventoryManager.

    onInventoryAdded

    Fired whenever a new Inventory is added.

    onInventoryManagerReset

    Fired whenever the InventoryManager is reset.

    onInventoryOverflow

    Fired whenever an Inventory is unable to add items because it's full (i.e. max quantity exceeded).

    onInventoryRemoved

    Fired whenever an Inventory is removed.

    onInventoryUnderflow

    Fired whenever an Inventory is unable to deduct items because it's empty (i.e. attempts to go BELOW 0 qty).

    onInventoryWillRemove

    Fired whenever an Inventory is about to be removed.

    wallet

    This is a reference to the "wallet" Inventory for the InventoryManager.

    Methods

    Name Description
    CreateInventory(int, string)

    This will create a new Inventory by specifying what InventoryDefinition to use by Hash.

    CreateInventory(string, string)

    This will create a new Inventory by specifying what InventoryDefinition Id to use.

    CreateInventory(InventoryDefinition, string)

    This will create a new Inventory by specifying what InventoryDefinition to use.

    GetInventories()

    Returns an array of all inventories in the manager.

    GetInventories(List<Inventory>)

    Fills the given list with all inventories in the manager.

    GetInventory(int)

    This will return the Inventory using the specified Inventory Hash.

    GetInventory(string)

    This will return the Inventory using the specified Inventory Id.

    GetNewInventoryId()

    Returns a unique Inventory Id that hasn't been registered to any existing Inventory. Use with CreateInventory().

    HasInventory(int)

    This method checks if an Inventory exists with the given Inventory Hash.

    HasInventory(string)

    This method checks if an Inventory exists with the given Inventory Id.

    HasInventoryByDefinition(int)

    This method checks if an Inventory exists for given InventoryDefinition Hash.

    HasInventoryByDefinition(string)

    This method checks if an Inventory exists with the given InventoryDefinition Id.

    HasInventoryByDefinition(InventoryDefinition)

    This method checks if an Inventory exists for specified InventoryDefinition.

    IsInventoryHashUnique(string)

    Checks if the given string Hash es to unique value and returns Hash as out variable, if it is.

    RemoveAllInventories(bool)

    This will simply clear out all Inventories.

    RemoveInventoriesByDefinition(int)

    This method will remove the Inventory that uses the InventoryDefinition with the given Hash.

    RemoveInventoriesByDefinition(string)

    This method will remove the Inventory that uses the InventoryDefinition with the given Id.

    RemoveInventoriesByDefinition(InventoryDefinition)

    This method will remove the Inventory that uses the given InventoryDefinition.

    RemoveInventory(int)

    This method will remove the Inventory with the given Inventory Hash.

    RemoveInventory(string)

    This method will remove the Inventory with the given instance Id.

    RemoveInventory(Inventory)

    This method will remove the given Inventory.

    Reset()

    Can be called after Initialize() as many times as needed. Will reset everything to be as it was after Initialize() was called.

    ThrowIfNotInitialized()

    Throws an exception if the InventoryManager has not been initialized.

    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)