| ExtensionMethodsTryAddComponentT Method |
Attempts to add a component to a GameObject. This can fail if there is already a component of some type on the GameObject, and only one is allowed.
Namespace:
DustProductions.Core
Assembly:
DustProductions.Core (in DustProductions.Core.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax public static bool TryAddComponent<T>(
this GameObject go,
out T addedComponent
)
where T : Component
Parameters
- go
- Type: GameObject
The GameObject to add the Component to. - addedComponent
- Type: T
The Component added, if one exists.
Type Parameters
- T
- The type of the Component to add.
Return Value
Type:
BooleanTrue if the component is added successfully, false otherwise.
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