docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method FindItemsByCategory

    FindItemsByCategory(Category, ICollection<TItem>)

    Fills in the given target collection with all TItem instances of this catalog matching the given category and returns their count. The target collection is cleared before being populated.

    Declaration
    public int FindItemsByCategory(Category category, ICollection<TItem> target = null)
    Parameters
    Type Name Description
    Category category

    The Category instance used as a filter

    ICollection<TItem> target

    The target container of all the matching TItem instances.

    Returns
    Type Description
    int

    The number of TItem instances matching the category filter in this catalog.

    Exceptions
    Type Condition
    ArgumentNullException

    If the category parameter is null

    FindItemsByCategory(string, ICollection<TItem>)

    Fills in the given target collection with all TItem instances of this catalog matching the Category by its id and returns their count. The target collection is cleared before being populated.

    Declaration
    public int FindItemsByCategory(string id, ICollection<TItem> target = null)
    Parameters
    Type Name Description
    string id

    The identifier of the Category used as a filter

    ICollection<TItem> target

    The target container of all the matching TItem instances.

    Returns
    Type Description
    int

    The number of TItem instances matching the category filter in this catalog.

    Exceptions
    Type Condition
    ArgumentException

    If the id parameter is null, empty or whitespace

    ArgumentException

    If there is no Category instance with the given id

    FindItemsByCategory(Category)

    Returns the array of all the TItem instances of this catalog matching the given Category.

    Declaration
    public TItem[] FindItemsByCategory(Category category)
    Parameters
    Type Name Description
    Category category

    The Category instance used as a filter

    Returns
    Type Description
    TItem[]

    The array of all the TItem instances matching the category filter in this catalog.

    Remarks

    Keep in mind that this method allocates an array. If you want to avoid allocations, please consider using FindItemsByCategory(Category, ICollection<TItem>) instead.

    Exceptions
    Type Condition
    ArgumentNullException

    If the category parameter is null.

    FindItemsByCategory(string)

    Returns an array of all the TItem instances of this catalog matching the Category by its id.

    Declaration
    public TItem[] FindItemsByCategory(string id)
    Parameters
    Type Name Description
    string id

    The identifier of the Category used as a filter

    Returns
    Type Description
    TItem[]

    The array of all the TItem instances matching the category filter in this catalog.

    Remarks

    Keep in mind that this method allocates an array. If you want to avoid allocations, please consider using FindItemsByCategory(string, ICollection<TItem>) instead.

    Exceptions
    Type Condition
    ArgumentException

    If the id parameter is null, empty or whitespace

    ArgumentException

    If there is no Category instance with the given id

    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)