A class in Root.Township, the global namespace.
A component that keeps a list of other components of one type, usually filled from its children in the editor. ColliderGroup builds on it.
- Listed in Global namespace: C to D
- Inherits or implements
MonoBehaviour, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IBuildRendererPostBake, IBuildBakeable
- Derived types
FixedImpactorGroup, CharacterDockManager, ColliderGroup, ControllerExtensionGroup, CopyBoneGroup, MaterialGroup, PickupDockGroup, RendererGroup, RigidbodyGroup, SkinnedMeshRendererGroup, VisibleNetworkRigidbody
- Nested types
GroupModifiedHandler
Constructors
| Member | What it is |
|---|
ComponentGroup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|
protected List<T> components | The backing list. |
3 private and internal fields
| Member | What it is |
|---|
private List<T> componentsToIgnoreWhenAdding | Components left out when collecting from children. |
private bool isAddingComponents | Inspector button flag for adding components in children. |
private List<Transform> parentsToIgnoreWhenAdding | Child transforms whose subtree is skipped when collecting. |
Properties
| Member | What it is |
|---|
List<T> Components { get; } | The list of grouped components. |
int Count { get; } | Number of grouped components. |
Events
| Member | What it is |
|---|
event ComponentGroup<T> ItemAdded | Raised when Add adds an item. |
event ComponentGroup<T> ItemRemoved | Raised when Remove removes an item. |
Methods
| Member | What it is |
|---|
void Add(T item) | Adds an item if it is not already in the list and raises ItemAdded. |
virtual void GetChildComponents(bool isAddingOn = false) | Fills the list from this object and its children, skipping ignored components and parents. Can add to the existing list. |
void Remove(T item) | Removes an item and raises ItemRemoved if it was there. |
void RemoveNullComponents() | Removes destroyed or missing entries from the list. |
protected virtual bool IsElementValid(T element) | Filter used by GetChildComponents. Accepts everything by default. |
protected virtual void OnValidate() | Editor hook. Empty in the base class. |
3 private and internal methods
| Member | What it is |
|---|
private IEnumerator System.Collections.IEnumerable.GetEnumerator() | Enumerates the components in the group. |
private void IBuildRendererPostBake.PostBake() | Build step: removes null entries from the list. |
private void RecursivlyAddComponents(Transform transform) | Adds every valid T on a transform and its children, skipping the ignore lists. |
Used in
Members of other types that take, return or hold a ComponentGroup<T>: