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: (
public static bool TryGetComponents<T1, T2>(
	this GameObject[] gameObjects,
	out List<T1> foundComponents,
	bool tryAddingComponents = false
where T1 : Component
where T2 : 


Type: GameObject
The array of GameObjects to search for the Components.
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

The type of component you are looking for
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