Click or drag to resize

ExtensionMethodsTryGetComponentsT1, T2 Method (GameObject, T1, Boolean)

Attempts to get components on a GameObject.

Namespace:  DustProductions.Core
Assembly:  DustProductions.Core (in DustProductions.Core.dll) Version: (
public static bool TryGetComponents<T1, T2>(
	this GameObject go,
	ref T1[] refComponentArray,
	bool tryAddingComponent = false
where T1 : Component
where T2 : 


Type: GameObject
The gameobject you are searching
Type: T1
A reference to the array of components found, if one is found
tryAddingComponent (Optional)
Type: SystemBoolean
Optional parameter to attempt adding the component if it 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 is found (either in the component array passed in, or on the object being searched) or successfully added

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type GameObject. 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