 | ExtensionMethodsTryGetComponentT1, T2 Method (Component, T1, Boolean) |
Attempts to get a component on a gameobject.
Namespace:
DustProductions.Core
Assembly:
DustProductions.Core (in DustProductions.Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic static bool TryGetComponent<T1, T2>(
this Component component,
ref T1 refComponent,
bool tryAddingComponent = false
)
where T1 : Component
where T2 :
Parameters
- component
- Type: Component
The component on the gameobject you are searching - refComponent
- Type: T1
A reference to the component found, if it exists - tryAddingComponent (Optional)
- Type: SystemBoolean
Optional parameter to attempt adding the component if it 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:
BooleanTrue if a component is found (either in the component 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
Component. 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