docs.unity3d.com
    Show / Hide Table of Contents

    Class CachedComponentFilter<TFilterType, TRootType>

    Provides utility functions to retrieve filtered lists of components. The lists created are automatically cached.

    Inheritance
    Object
    CachedComponentFilter<TFilterType, TRootType>
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils
    Syntax
    public class CachedComponentFilter<TFilterType, TRootType> : IDisposable where TFilterType : class where TRootType : Component
    Type Parameters
    Name Description
    TFilterType

    The type of component to find.

    TRootType

    The type of component at the root of the hierarchy.

    Remarks

    Proper usage of this class is:

    using (var componentFilter = new CachedComponentFilter<typeToFind,componentTypeThatContains>(instanceOfComponent))
    {
    
    }

    Constructors

    CachedComponentFilter(TFilterType[], Boolean)

    Initializes a new cached component filter.

    Declaration
    public CachedComponentFilter(TFilterType[] componentList, bool includeDisabled = true)
    Parameters
    Type Name Description
    TFilterType[] componentList

    The array of objects to use.

    Boolean includeDisabled

    Whether to include components on disabled objects.

    CachedComponentFilter(TRootType, CachedSearchType, Boolean)

    Initializes a new cached component filter.

    Declaration
    public CachedComponentFilter(TRootType componentRoot, CachedSearchType cachedSearchType = CachedSearchType.Children | CachedSearchType.Self, bool includeDisabled = true)
    Parameters
    Type Name Description
    TRootType componentRoot

    The component at the root of the hierarchy.

    CachedSearchType cachedSearchType

    What type of hierarchy traversal to perform.

    Boolean includeDisabled

    Whether to include components on disabled objects.

    Methods

    Dispose()

    Part of the IDisposable pattern.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    Dispose(Boolean)

    Disposes of the cached component filter.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    Whether or not to dispose the contents of this object.

    See Also
    Implement a Dispose method

    GetMatchingComponents<TChildType>()

    Get an array of matching components.

    Declaration
    public TChildType[] GetMatchingComponents<TChildType>()
        where TChildType : class, TFilterType
    Returns
    Type Description
    TChildType[]

    The array of matching components.

    Type Parameters
    Name Description
    TChildType

    The type for which to search. Must inherit from or be TFilterType.

    StoreMatchingComponents<TChildType>(List<TChildType>)

    Store components that match TChildType.

    Declaration
    public void StoreMatchingComponents<TChildType>(List<TChildType> outputList)
        where TChildType : class, TFilterType
    Parameters
    Type Name Description
    List<TChildType> outputList

    The list to which to add matching components.

    Type Parameters
    Name Description
    TChildType

    The type for which to search. Must inherit from or be TFilterType.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023