The Inventory Manager | Game Foundation | 0.8.0-preview
docs.unity.cn
    Show / Hide Table of Contents

    The Inventory Manager

    Overview

    The Inventory Manager is a central piece of the Game Foundation architecture. It tracks all Inventory Items in a player's inventory acquired through an In-App Purchase, a Virtual Transaction, or a script in response to a game event. Inventory Items can track player progress, purchases, rewards, etc. and can also be used by your Game Economy to provide objectives and track game play accomplishments.

    Main inventory example
    Example: the main inventory contains characters, hats, bonuses, and themes.

    Creating/Removing items

    In order to create an item, the Inventory Manager requires an Inventory Item Definition. This definition can be found in the Catalog and passed to the CreateItem() method, or specified with its Key.

    When created, an item is assigned a unique identifier (ID), and its properties are initialized with their default values.

    Getting items

    The Inventory Manager provides some methods to retrieve items, or find specific items by their ID, their definition or their tags

    Some of the methods allocate an array to return the collection of items found. You'll also find a non-allocating version of those methods, accepting a target collection.

    Removing items

    To remove items, the Inventory Manager exposes various methods:

    • Removing one item by passing its reference.
    • Removing one item by passing its ID.
    • Removing items by their definition.
    • Removing all the items.

    Removing items from the Inventory Manager doesn't destroy the item object in memory. It wouldn't be an expected behaviour for a managed language like C#. Instead, the items are discarded: they are removed from the data layer and they cannot be part of any process, but their ID, display name and definition remain accessible.

    < table of contents

    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on 23 November 2020