Class CachedComponentFilter<TFilterType, TRootType>
Provides utility functions to retrieve filtered lists of components. The lists created are automatically cached.
Implements
Inherited Members
Namespace: Unity.XR.CoreUtils
Assembly: Unity.XR.CoreUtils.dll
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. |
Examples
Proper usage of this class is:
using (var componentFilter = new CachedComponentFilter<typeToFind,componentTypeThatContains>(instanceOfComponent))
{
}
Constructors
CachedComponentFilter(TFilterType[], bool)
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. |
| bool | includeDisabled | Whether to include components on disabled objects. |
CachedComponentFilter(TRootType, CachedSearchType, bool)
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. |
| bool | includeDisabled | Whether to include components on disabled objects. |
Methods
Dispose()
Part of the IDisposable pattern.
Declaration
public void Dispose()
Dispose(bool)
Disposes of the cached component filter.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | Whether or not to dispose the contents of this object. |
See Also
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. |