Photon Fusion 2.0.3

Static Public Member Functions | List of all members
NestedComponentUtilities Class Reference

Tools to replace GetComponent variants that respects nested objects. These are used to find components of a NetworkedObjects without also finding components that belong to parent or child NetworkedObjects. More...

Static Public Member Functions

static T EnsureRootComponentExists< T, TStopOn > (this Transform transform)
 Ensures that a component of type T exists on the root object of the provided transform. If a component of type T does not exist, it is added. The search for the root object stops if a component of type TStopOn is found. More...
 
static T[] FindObjectsOfTypeInOrder< T > (this UnityEngine.SceneManagement.Scene scene, bool includeInactive=false)
 Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slower operation, and does produce garbage collection. More...
 
static void FindObjectsOfTypeInOrder< T > (this UnityEngine.SceneManagement.Scene scene, List< T > list, bool includeInactive=false)
 Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slower operation which should not be run every update. More...
 
static TCast[] FindObjectsOfTypeInOrder< T, TCast > (this UnityEngine.SceneManagement.Scene scene, bool includeInactive=false)
 Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slow operation, and does produce garbage collection. More...
 
static void FindObjectsOfTypeInOrder< T, TCast > (this UnityEngine.SceneManagement.Scene scene, List< TCast > list, bool includeInactive=false)
 Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slower operation and should not be run every update. More...
 
static T GetNestedComponentInChildren< T, TStopOn > (this Transform t, bool includeInactive)
 Finds the first component of type T in the children of the provided transform, stopping the search if a component of type TStopOn is found. More...
 
static T GetNestedComponentInParent< T, TStopOn > (this Transform t)
 Same as GetComponentInParent, but will always include inactive objects in search. Will also stop recursing up the hierarchy when the StopOnT is found. More...
 
static T GetNestedComponentInParents< T, TStopOn > (this Transform t)
 Finds the first component of type T in the parents of the provided transform, stopping the search if a component of type TStopOn is found. More...
 
static List< T > GetNestedComponentsInChildren< T > (this Transform t, List< T > list, bool includeInactive=true, params System.Type[] stopOn)
 Same as GetComponentsInChildren, but will not recurse into children with any component of the types in the stopOn array. More...
 
static void GetNestedComponentsInChildren< T, TSearch, TStop > (this Transform t, bool includeInactive, List< T > list)
 Same as GetComponentsInChildren, but will not recurse into children with component of the StopT type. More...
 
static List< T > GetNestedComponentsInChildren< T, TStopOn > (this Transform t, List< T > list, bool includeInactive=true)
 Same as GetComponentsInChildren, but will not recurse into children with component of the StopT type. More...
 
static void GetNestedComponentsInParents< T > (this Transform t, List< T > list)
 Returns all T found between the child transform and its root. Order in List from child to parent, with the root/parent most being last. More...
 
static void GetNestedComponentsInParents< T, TStop > (this Transform t, List< T > list)
 Finds components of type T on supplied transform, and every parent above that node, inclusively stopping on node StopT component. More...
 
static T GetParentComponent< T > (this Transform t)
 Find T on supplied transform or any parent. Unlike GetComponentInParent, GameObjects do not need to be active to be found. More...
 

Detailed Description

Tools to replace GetComponent variants that respects nested objects. These are used to find components of a NetworkedObjects without also finding components that belong to parent or child NetworkedObjects.

Member Function Documentation

◆ EnsureRootComponentExists< T, TStopOn >()

static T EnsureRootComponentExists< T, TStopOn > ( this Transform  transform)
static

Ensures that a component of type T exists on the root object of the provided transform. If a component of type T does not exist, it is added. The search for the root object stops if a component of type TStopOn is found.

Template Parameters
TThe type of component to ensure exists on the root object.
TStopOnThe type of component that stops the search for the root object.
Parameters
transformThe transform to start the search from.
Returns
The component of type T on the root object. Returns null if no root object is found.
Type Constraints
T :Component 
TStopOn :Component 

◆ FindObjectsOfTypeInOrder< T >() [1/2]

static T [] FindObjectsOfTypeInOrder< T > ( this UnityEngine.SceneManagement.Scene  scene,
bool  includeInactive = false 
)
static

Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slower operation, and does produce garbage collection.

Type Constraints
T :class 

◆ FindObjectsOfTypeInOrder< T >() [2/2]

static void FindObjectsOfTypeInOrder< T > ( this UnityEngine.SceneManagement.Scene  scene,
List< T >  list,
bool  includeInactive = false 
)
static

Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slower operation which should not be run every update.

Template Parameters
TThe type being searched for.
Parameters
sceneScene to search.
listSupplied list that will be populated by this find.
includeInactiveWhether results should include inactive components.
Type Constraints
T :class 

◆ FindObjectsOfTypeInOrder< T, TCast >() [1/2]

static TCast [] FindObjectsOfTypeInOrder< T, TCast > ( this UnityEngine.SceneManagement.Scene  scene,
bool  includeInactive = false 
)
static

Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slow operation, and does produce garbage collection.

Template Parameters
TThe type being searched for.
TCastCasts all found objects to this type, and returns collection of this type. Objects that fail cast are excluded.
Parameters
sceneScene to search.
includeInactiveWhether results should include inactive components.
Type Constraints
T :class 
TCast :class 

◆ FindObjectsOfTypeInOrder< T, TCast >() [2/2]

static void FindObjectsOfTypeInOrder< T, TCast > ( this UnityEngine.SceneManagement.Scene  scene,
List< TCast >  list,
bool  includeInactive = false 
)
static

Find All instances of Component type in a scene. Attempts to respect the hierarchy of the scene objects to produce a more deterministic order. This is a slower operation and should not be run every update.

Template Parameters
TType being searched for.
TCastType to cast found objects to.
Parameters
sceneScene to search.
listSupplied list that will be filled with found objects.
includeInactiveWhether results should include inactive components.
Type Constraints
T :class 
TCast :class 

◆ GetNestedComponentInChildren< T, TStopOn >()

static T GetNestedComponentInChildren< T, TStopOn > ( this Transform  t,
bool  includeInactive 
)
static

Finds the first component of type T in the children of the provided transform, stopping the search if a component of type TStopOn is found.

Template Parameters
TThe type of component to find.
TStopOnThe type of component that stops the search.
Parameters
tThe transform to start the search from.
includeInactiveWhether to include inactive game objects in the search.
Returns
The first component of type T found. Returns null if no component is found.
Type Constraints
T :class 
TStopOn :class 

◆ GetNestedComponentInParent< T, TStopOn >()

static T GetNestedComponentInParent< T, TStopOn > ( this Transform  t)
static

Same as GetComponentInParent, but will always include inactive objects in search. Will also stop recursing up the hierarchy when the StopOnT is found.

Type Constraints
T :class 
TStopOn :class 

◆ GetNestedComponentInParents< T, TStopOn >()

static T GetNestedComponentInParents< T, TStopOn > ( this Transform  t)
static

Finds the first component of type T in the parents of the provided transform, stopping the search if a component of type TStopOn is found.

Template Parameters
TThe type of component to find.
TStopOnThe type of component that stops the search.
Parameters
tThe transform to start the search from.
Returns
The first component of type T found in the parents. Returns null if no component is found or a component of type TStopOn is found.
Type Constraints
T :class 
TStopOn :class 

◆ GetNestedComponentsInChildren< T >()

static List<T> GetNestedComponentsInChildren< T > ( this Transform  t,
List< T >  list,
bool  includeInactive = true,
params System.Type[]  stopOn 
)
static

Same as GetComponentsInChildren, but will not recurse into children with any component of the types in the stopOn array.

Type Constraints
T :class 

◆ GetNestedComponentsInChildren< T, TSearch, TStop >()

static void GetNestedComponentsInChildren< T, TSearch, TStop > ( this Transform  t,
bool  includeInactive,
List< T >  list 
)
static

Same as GetComponentsInChildren, but will not recurse into children with component of the StopT type.

Template Parameters
TCast found components to this type. Typically Component, but any other class/interface will work as long as they are assignable from SearchT.
TSearchFind components of this class or interface type.
TStopWhen this component is found, no further recursing will be performed on that node.
Type Constraints
T :class 
TSearch :class 

◆ GetNestedComponentsInChildren< T, TStopOn >()

static List<T> GetNestedComponentsInChildren< T, TStopOn > ( this Transform  t,
List< T >  list,
bool  includeInactive = true 
)
static

Same as GetComponentsInChildren, but will not recurse into children with component of the StopT type.

Type Constraints
T :class 
TStopOn :class 

◆ GetNestedComponentsInParents< T >()

static void GetNestedComponentsInParents< T > ( this Transform  t,
List< T >  list 
)
static

Returns all T found between the child transform and its root. Order in List from child to parent, with the root/parent most being last.

Type Constraints
T :Component 

◆ GetNestedComponentsInParents< T, TStop >()

static void GetNestedComponentsInParents< T, TStop > ( this Transform  t,
List< T >  list 
)
static

Finds components of type T on supplied transform, and every parent above that node, inclusively stopping on node StopT component.

Type Constraints
T :class 
TStop :class 

◆ GetParentComponent< T >()

static T GetParentComponent< T > ( this Transform  t)
static

Find T on supplied transform or any parent. Unlike GetComponentInParent, GameObjects do not need to be active to be found.

Type Constraints
T :Component