Class CachedComponentFilter<TFilterType, TRootType>
Class that allows for cached retrieval/filtering of multiple types of components into lists Proper usage of this class is:
using (var componentFilter = new CachedComponentFilter<typeToFind,componentTypeThatContains>(instanceOfComponent))
{
}
Namespace: Unity.XRTools.Utils
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 |
Constructors
CachedComponentFilter(TFilterType[], Boolean)
Initialize 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)
Initialize 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()
Dispose(Boolean)
Dispose 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 |
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 which 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 matching components will be added |
Type Parameters
Name | Description |
---|---|
TChildType | The type for which to search. Must inherit from or be TFilterType |