| ExtensionMethodsTryGetComponentsT Method (GameObject, ListT, 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 public static bool TryGetComponents<T>(
this GameObject[] gameObjects,
out List<T> foundComponents,
bool tryAddingComponents = false
)
where T : Component
Parameters
- gameObjects
- Type: GameObject
The array of GameObjects to search for the Components. - foundComponents
- Type: System.Collections.GenericListT
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
- T
- The type of component you are looking for
Return Value
Type:
BooleanTrue 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