Click or drag to resize

ExtensionMethodsTryGetComponentsT1, T2 Method (GameObject, ListT1, Boolean)

Searches an array of GameObjects for a certain Type of Component. Can also add it if it doesn't exist.

Namespace:  DustProductions.Core
Assembly:  DustProductions.Core (in DustProductions.Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static bool TryGetComponents<T1, T2>(
	this GameObject[] gameObjects,
	out List<T1> foundComponents,
	bool tryAddingComponents = false
)
where T1 : Component
where T2 : 

Parameters

gameObjects
Type: GameObject
The array of GameObjects to search for the Components.
foundComponents
Type: System.Collections.GenericListT1
A List of Components we found, if any exist.
tryAddingComponents (Optional)
Type: SystemBoolean
Optional parameter to attempt adding the Components if they cannot be found, defaulted to false

Type Parameters

T1
The type of component you are looking for
T2
The type of component to add, if we are going to add one.

Return Value

Type: Boolean
True if a Component of the desired Type can be found, false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also