Extensions for working with GameObjects.
More...
|
static T | GetOrAddComponent< T > (this GameObject gameObject, bool checkParents) |
| Either gets a component on the given game object or adds one.
|
|
static bool | ShareParent (Transform a, Transform b, Transform parent=null) |
| Checks if both of the given transforms have the same parent.
|
|
static bool | HasParent (Transform a, Transform parent) |
| Checks if the given transform has the given parent.
|
|
static bool | IsAlive (this Object obj) |
| Checks if the given object is not null and not destroyed.
|
|
static bool | IsDestroyed (this Object obj) |
| Checks if the given object is destroyed.
|
|
Extensions for working with GameObjects.
◆ GetOrAddComponent< T >()
static T ImpactCFX.GameObjectExtensions.GetOrAddComponent< T > |
( |
this GameObject |
gameObject, |
|
|
bool |
checkParents |
|
) |
| |
|
static |
Either gets a component on the given game object or adds one.
- Template Parameters
-
- Parameters
-
gameObject | The game object to get or add the component to. |
checkParents | Should we look for the component in parent objects? |
- Returns
- A reference to the existing or new component.
◆ HasParent()
static bool ImpactCFX.GameObjectExtensions.HasParent |
( |
Transform |
a, |
|
|
Transform |
parent |
|
) |
| |
|
static |
Checks if the given transform has the given parent.
- Parameters
-
a | The transform. |
parent | Parent to check for. |
- Returns
- True if the transform has the parent, false otherwise.
◆ IsAlive()
static bool ImpactCFX.GameObjectExtensions.IsAlive |
( |
this Object |
obj | ) |
|
|
static |
Checks if the given object is not null and not destroyed.
- Parameters
-
obj | The object to check (can be null). |
- Returns
- True if the object is still alive in the scene, false otherwise.
◆ IsDestroyed()
static bool ImpactCFX.GameObjectExtensions.IsDestroyed |
( |
this Object |
obj | ) |
|
|
static |
Checks if the given object is destroyed.
- Parameters
-
obj | The object to check (can be null). |
- Returns
- True if the object is null or destroyed, false otherwise.
◆ ShareParent()
static bool ImpactCFX.GameObjectExtensions.ShareParent |
( |
Transform |
a, |
|
|
Transform |
b, |
|
|
Transform |
parent = null |
|
) |
| |
|
static |
Checks if both of the given transforms have the same parent.
- Parameters
-
a | The first transform. |
b | The second transform. |
parent | Optional parent to check for. If null, the root parent of both transforms will be checked. |