docs.unity.cn
    Show / Hide Table of Contents

    Class InventoryItemDefinition

    Preset values and rules for an InventoryItem. During runtime, it may be useful to refer back to the InventoryItemDefinition for the presets and rules, but the values cannot be changed at runtime. InventoryItemDefinitions are also used as factories to create InventoryItems.

    Inheritance
    Object
    CatalogItem
    TradableDefinition
    InventoryItemDefinition
    StackableInventoryItemDefinition
    Inherited Members
    CatalogItem.displayName
    CatalogItem.key
    CatalogItem.GetTags(ICollection<Tag>, Boolean)
    CatalogItem.HasTag(Tag)
    CatalogItem.GetHashCode()
    CatalogItem.Equals(Object)
    CatalogItem.GetStaticProperties()
    CatalogItem.GetStaticProperties(Dictionary<String, Property>)
    CatalogItem.HasStaticProperty(String)
    CatalogItem.GetStaticProperty(String)
    CatalogItem.TryGetStaticProperty(String, Property)
    CatalogItem.Item[String]
    Namespace: UnityEngine.GameFoundation
    Syntax
    public class InventoryItemDefinition : TradableDefinition, IEquatable<CatalogItem>, IComparable<CatalogItem>

    Methods

    GetDefaultValueOfMutableProperty(String)

    Get the default value of the mutable property with the given propertyKey.

    Declaration
    public Property GetDefaultValueOfMutableProperty(string propertyKey)
    Parameters
    Type Name Description
    String propertyKey

    Identifier of the mutable property to get the value of.

    Returns
    Type Description
    Property

    The default value of the mutable property with the given propertyKey.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the given propertyKey is null, empty, or whitespace.

    PropertyNotFoundException

    Thrown if there is no mutable property with the given propertyKey in this item.

    GetDefaultValuesOfMutableProperties()

    Get all default properties stored in this definition.

    Declaration
    public Dictionary<string, Property> GetDefaultValuesOfMutableProperties()
    Returns
    Type Description
    Dictionary<String, Property>

    Return a new dictionary containing all properties stored in this definition. The returned dictionary is never null.

    GetDefaultValuesOfMutableProperties(Dictionary<String, Property>)

    Get all default values of mutable properties stored in this definition.

    Declaration
    public void GetDefaultValuesOfMutableProperties(Dictionary<string, Property> target)
    Parameters
    Type Name Description
    Dictionary<String, Property> target

    The dictionary to fill with the mutable properties stored in this definition. It is cleared before being filled.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the given target is null.

    HasMutableProperty(String)

    Check if this definition has a mutable property with the given propertyKey.

    Declaration
    public bool HasMutableProperty(string propertyKey)
    Parameters
    Type Name Description
    String propertyKey

    The identifier of the mutable property to look for.

    Returns
    Type Description
    Boolean

    true if this definition has a mutable property with the given propertyKey; false otherwise.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the given propertyKey is null, empty, or whitespace.

    TryGetDefaultValueOfMutableProperty(String, out Property)

    Try to get the default value of the mutable property with the given propertyKey.

    Declaration
    public bool TryGetDefaultValueOfMutableProperty(string propertyKey, out Property property)
    Parameters
    Type Name Description
    String propertyKey

    Identifier of the mutable property to get the value of.

    Property property

    The default value of the searched mutable property, if found.

    Returns
    Type Description
    Boolean

    Returns true if a mutable property with the given propertyKey exists on this item; returns false otherwise.

    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on 16 June 2021