docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method FindItemsByTag

    FindItemsByTag(Tag, ICollection<TItem>)

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

    Declaration
    public int FindItemsByTag(Tag tag, ICollection<TItem> target = null)
    Parameters
    Type Name Description
    Tag tag

    The Tag 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 tag filter in this catalog.

    Exceptions
    Type Condition
    ArgumentNullException

    If the tag parameter is null

    FindItemsByTag(string, ICollection<TItem>)

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

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

    The identifier of the Tag 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 tag filter in this catalog.

    Exceptions
    Type Condition
    ArgumentException

    If the key parameter is null, empty or whitespace

    ArgumentException

    If there is no Tag instance with the given key

    FindItemsByTag(Tag)

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

    Declaration
    public TItem[] FindItemsByTag(Tag tag)
    Parameters
    Type Name Description
    Tag tag

    The Tag instance used as a filter

    Returns
    Type Description
    TItem[]

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

    Remarks

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

    Exceptions
    Type Condition
    ArgumentNullException

    If the tag parameter is null.

    FindItemsByTag(string)

    Returns an array of all the TItem instances of this catalog matching the Tag by its key.

    Declaration
    public TItem[] FindItemsByTag(string key)
    Parameters
    Type Name Description
    string key

    The identifier of the Tag used as a filter

    Returns
    Type Description
    TItem[]

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

    Remarks

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

    Exceptions
    Type Condition
    ArgumentException

    If the key parameter is null, empty or whitespace

    ArgumentException

    If there is no Tag instance with the given key

    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)