Skip to Main Content

BTD_Mod_Helper​.Extensions​.GameObjectExt


BloonsTD6 Mod Helper

BTD_Mod_Helper.Extensions

GameObjectExt Class

Extensions for GameObjects

public static class GameObjectExt

Inheritance System.Object  GameObjectExt

Methods

GameObjectExt.AddModHelperComponent(this GameObject, T) Method

Adds the ModHelperComponent to a parent GameObject, returning the ModHelperComponent


(This is an extension method just so that we can return the type generically)

public static T AddModHelperComponent<T>(this GameObject gameObject, T modHelperComponent)
    where T : BTD_Mod_Helper.Api.Components.ModHelperComponent;

Type parameters

T

Parameters

gameObject UnityEngine.GameObject

modHelperComponent T

Returns

T

GameObjectExt.Destroy(this GameObject) Method

Destroys this GameObject

public static void Destroy(this GameObject gameObject);

Parameters

gameObject UnityEngine.GameObject

GameObjectExt.DestroyAllChildren(this GameObject) Method

Destroys all children of a game object

public static void DestroyAllChildren(this GameObject gameObject);

Parameters

gameObject UnityEngine.GameObject

GameObjectExt.Duplicate(this T, Transform) Method

Instantiate a clone of the GameObject with the new transform as parent

public static T Duplicate<T>(this T gameObject, Transform parent)
    where T : Object;

Type parameters

T

Parameters

gameObject T

parent UnityEngine.Transform

Returns

T

GameObjectExt.Duplicate(this T) Method

Instantiate a clone of the GameObject keeping the same parent

public static T Duplicate<T>(this T gameObject)
    where T : Object;

Type parameters

T

Parameters

gameObject T

Returns

T

GameObjectExt.Exists(this T, T) Method

Used to null check unity objects without bypassing the lifecycle

public static bool Exists<T>(this T obj, out T result)
    where T : Object;

Type parameters

T

Parameters

obj T

result T

Returns

System.Boolean

GameObjectExt.Exists(this T) Method

Used to null check unity objects without bypassing the lifecycle

public static T Exists<T>(this T obj)
    where T : Object;

Type parameters

T

Parameters

obj T

Returns

T

GameObjectExt.GetComponent(this GameObject, string) Method

Finds a component with the given path and type

public static T GetComponent<T>(this GameObject gameObject, string componentPath);

Type parameters

T

Parameters

gameObject UnityEngine.GameObject

componentPath System.String

Returns

T

GameObjectExt.GetComponentInChildrenByName(this GameObject, string) Method

Try to get a component in a child of this GameObject by it's name. Equivelant to a foreach with GetComponentsInChildren

public static T GetComponentInChildrenByName<T>(this GameObject gameObject, string componentName)
    where T : Component;

Type parameters

T

Parameters

gameObject UnityEngine.GameObject

componentName System.String

Returns

T

GameObjectExt.HasComponent(this GameObject, T) Method

Returns whether a component of the given type exists on a game object, and puts it in the out param

public static bool HasComponent<T>(this GameObject gameObject, out T component)
    where T : Component;

Type parameters

T

Parameters

gameObject UnityEngine.GameObject

component T

Returns

System.Boolean

GameObjectExt.HasComponent(this GameObject) Method

Returns whether a component of the given type exists on a game object

public static bool HasComponent<T>(this GameObject gameObject)
    where T : Component;

Type parameters

T

Parameters

gameObject UnityEngine.GameObject

Returns

System.Boolean

GameObjectExt.Hide(this GameObject) Method

Makes the Game Object hidden (not visible) by setting the scale to zero

public static void Hide(this GameObject gameObject);

Parameters

gameObject UnityEngine.GameObject

GameObjectExt.RecursivelyLog(this GameObject, int) Method

Logs a GameObject's hierarchy recursively

public static void RecursivelyLog(this GameObject gameObject, int depth=0);

Parameters

gameObject UnityEngine.GameObject

depth System.Int32

GameObjectExt.RemoveComponent(this GameObject) Method

Removes a Component from a GameObject by destroying it

public static void RemoveComponent<T>(this GameObject gameObject)
    where T : Component;

Type parameters

T

Parameters

gameObject UnityEngine.GameObject

GameObjectExt.Show(this GameObject) Method

Makes the Game Object visible by setting the scale to the default value of 1

public static void Show(this GameObject gameObject);

Parameters

gameObject UnityEngine.GameObject

GameObjectExt.TranslateScaled(this GameObject, Vector3) Method

Translates this GameObject scaled with it's "lossyScale", making it move the same
amount regardless of screen resolution

public static void TranslateScaled(this GameObject gameObject, Vector3 translation);

Parameters

gameObject UnityEngine.GameObject

translation UnityEngine.Vector3

To learn how to download BTD Mod Helper and install mods, click here