Skip to Main Content
Table of Contents

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.AddButton(this GameObject, Info, string, Action) Method

Creates a new ModHelperButton

public static BTD_Mod_Helper.Api.Components.ModHelperButton AddButton(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string sprite, System.Action onClick);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

sprite System.String

The button's visuals

onClick System.Action

What should happen when the button is clicked

Returns

ModHelperButton

GameObjectExt.AddCheckbox(this GameObject, Info, bool, string, UnityAction, string, int) Method

Creates a new ModHelperCheckbox

public static BTD_Mod_Helper.Api.Components.ModHelperCheckbox AddCheckbox(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, bool defaultValue, string background, UnityAction<bool> onValueChanged, string checkImage, int padding);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

defaultValue System.Boolean

If it starts out checked or not

background System.String

The background behind the check, or null for nothing

onValueChanged UnityEngine.Events.UnityAction

Action to perform when it is checked/unchecked, or null

checkImage System.String

The checkmark itself, or null for the default checkmark

padding System.Int32

How much space around the outside of the check there is

Returns

ModHelperCheckbox
The new ModHelperCheckbox

GameObjectExt.AddCheckbox(this GameObject, Info, bool, string, UnityAction, string) Method

Creates a new ModHelperCheckbox

public static BTD_Mod_Helper.Api.Components.ModHelperCheckbox AddCheckbox(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, bool defaultValue, string background, UnityAction<bool> onValueChanged, string checkImage);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

defaultValue System.Boolean

If it starts out checked or not

background System.String

The background behind the check, or null for nothing

onValueChanged UnityEngine.Events.UnityAction

Action to perform when it is checked/unchecked, or null

checkImage System.String

The checkmark itself, or null for the default checkmark

Returns

ModHelperCheckbox
The new ModHelperCheckbox

GameObjectExt.AddCheckbox(this GameObject, Info, bool, string, UnityAction) Method

Creates a new ModHelperCheckbox

public static BTD_Mod_Helper.Api.Components.ModHelperCheckbox AddCheckbox(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, bool defaultValue, string background, UnityAction<bool> onValueChanged);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

defaultValue System.Boolean

If it starts out checked or not

background System.String

The background behind the check, or null for nothing

onValueChanged UnityEngine.Events.UnityAction

Action to perform when it is checked/unchecked, or null

Returns

ModHelperCheckbox
The new ModHelperCheckbox

GameObjectExt.AddCheckbox(this GameObject, Info, bool, string) Method

Creates a new ModHelperCheckbox

public static BTD_Mod_Helper.Api.Components.ModHelperCheckbox AddCheckbox(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, bool defaultValue, string background);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

defaultValue System.Boolean

If it starts out checked or not

background System.String

The background behind the check, or null for nothing

Returns

ModHelperCheckbox
The new ModHelperCheckbox

GameObjectExt.AddDropdown(this GameObject, Info, List, float, UnityAction, string, float) Method

Creates a new ModHelperDropdown

public static BTD_Mod_Helper.Api.Components.ModHelperDropdown AddDropdown(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, List<string> options, float windowHeight, UnityAction<int> onValueChanged, string background, float labelFontSize);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: width/height must be set to actual values

options Il2CppSystem.Collections.Generic.List

The list of options

windowHeight System.Single

Height of the created dropdown window

onValueChanged UnityEngine.Events.UnityAction

Action that should happen when an option of the given index is selected

background System.String

The background image

labelFontSize System.Single

Text size of label

Returns

ModHelperDropdown
The created ModHelperDropdown

GameObjectExt.AddDropdown(this GameObject, Info, List, float, UnityAction, string) Method

Creates a new ModHelperDropdown

public static BTD_Mod_Helper.Api.Components.ModHelperDropdown AddDropdown(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, List<string> options, float windowHeight, UnityAction<int> onValueChanged, string background);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: width/height must be set to actual values

options Il2CppSystem.Collections.Generic.List

The list of options

windowHeight System.Single

Height of the created dropdown window

onValueChanged UnityEngine.Events.UnityAction

Action that should happen when an option of the given index is selected

background System.String

The background image

Returns

ModHelperDropdown
The created ModHelperDropdown

GameObjectExt.AddDropdown(this GameObject, Info, List, float, UnityAction) Method

Creates a new ModHelperDropdown

public static BTD_Mod_Helper.Api.Components.ModHelperDropdown AddDropdown(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, List<string> options, float windowHeight, UnityAction<int> onValueChanged);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: width/height must be set to actual values

options Il2CppSystem.Collections.Generic.List

The list of options

windowHeight System.Single

Height of the created dropdown window

onValueChanged UnityEngine.Events.UnityAction

Action that should happen when an option of the given index is selected

Returns

ModHelperDropdown
The created ModHelperDropdown

GameObjectExt.AddImage(this GameObject, Info, Sprite) Method

Creates a new ModHelperImage

public static BTD_Mod_Helper.Api.Components.ModHelperImage AddImage(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, Sprite sprite);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

sprite UnityEngine.Sprite

The sprite to display

Returns

ModHelperImage
The created ModHelperImage

GameObjectExt.AddImage(this GameObject, Info, string) Method

Creates a new ModHelperImage

public static BTD_Mod_Helper.Api.Components.ModHelperImage AddImage(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string sprite);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

sprite System.String

The sprite to display

Returns

ModHelperImage
The created ModHelperImage

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.AddSlider(this GameObject, Info, float, float, float, float, Vector2, UnityAction, float, string, float) Method

Creates a new ModHelperSlider

public static BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, float defaultValue, float minValue, float maxValue, float stepSize, Vector2 handleSize, UnityAction<float> onValueChanged, float fontSize, string labelSuffix, float startingValue);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: height must be a set value

defaultValue System.Single

The default slider amount

minValue System.Single

The minimum value of the slider

maxValue System.Single

The maximum value of the slider

stepSize System.Single

What value the slider should increase by per tick

handleSize UnityEngine.Vector2

The height and width of the pip

onValueChanged UnityEngine.Events.UnityAction

Action should happen when the slider changes value, or null

fontSize System.Single

The size of the label text

labelSuffix System.String

String to add to the end of the label, e.g. "%"

startingValue System.Single

If not null, the value that this should start as instead of the default

Returns

ModHelperSlider

GameObjectExt.AddSlider(this GameObject, Info, float, float, float, float, Vector2, UnityAction, float, string) Method

Creates a new ModHelperSlider

public static BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, float defaultValue, float minValue, float maxValue, float stepSize, Vector2 handleSize, UnityAction<float> onValueChanged, float fontSize, string labelSuffix);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: height must be a set value

defaultValue System.Single

The default slider amount

minValue System.Single

The minimum value of the slider

maxValue System.Single

The maximum value of the slider

stepSize System.Single

What value the slider should increase by per tick

handleSize UnityEngine.Vector2

The height and width of the pip

onValueChanged UnityEngine.Events.UnityAction

Action should happen when the slider changes value, or null

fontSize System.Single

The size of the label text

labelSuffix System.String

String to add to the end of the label, e.g. "%"

Returns

ModHelperSlider

GameObjectExt.AddSlider(this GameObject, Info, float, float, float, float, Vector2, UnityAction, float) Method

Creates a new ModHelperSlider

public static BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, float defaultValue, float minValue, float maxValue, float stepSize, Vector2 handleSize, UnityAction<float> onValueChanged, float fontSize);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: height must be a set value

defaultValue System.Single

The default slider amount

minValue System.Single

The minimum value of the slider

maxValue System.Single

The maximum value of the slider

stepSize System.Single

What value the slider should increase by per tick

handleSize UnityEngine.Vector2

The height and width of the pip

onValueChanged UnityEngine.Events.UnityAction

Action should happen when the slider changes value, or null

fontSize System.Single

The size of the label text

Returns

ModHelperSlider

GameObjectExt.AddSlider(this GameObject, Info, float, float, float, float, Vector2, UnityAction) Method

Creates a new ModHelperSlider

public static BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, float defaultValue, float minValue, float maxValue, float stepSize, Vector2 handleSize, UnityAction<float> onValueChanged);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: height must be a set value

defaultValue System.Single

The default slider amount

minValue System.Single

The minimum value of the slider

maxValue System.Single

The maximum value of the slider

stepSize System.Single

What value the slider should increase by per tick

handleSize UnityEngine.Vector2

The height and width of the pip

onValueChanged UnityEngine.Events.UnityAction

Action should happen when the slider changes value, or null

Returns

ModHelperSlider

GameObjectExt.AddSlider(this GameObject, Info, float, float, float, float, Vector2) Method

Creates a new ModHelperSlider

public static BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, float defaultValue, float minValue, float maxValue, float stepSize, Vector2 handleSize);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info. NOTE: height must be a set value

defaultValue System.Single

The default slider amount

minValue System.Single

The minimum value of the slider

maxValue System.Single

The maximum value of the slider

stepSize System.Single

What value the slider should increase by per tick

handleSize UnityEngine.Vector2

The height and width of the pip

Returns

ModHelperSlider

GameObjectExt.AddText(this GameObject, Info, string, float, TextAlignmentOptions) Method

Creates a new ModHelperText

public static BTD_Mod_Helper.Api.Components.ModHelperText AddText(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string text, float fontSize, TextAlignmentOptions align);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

text System.String

The text to display

fontSize System.Single

Size of font

align Il2CppTMPro.TextAlignmentOptions

Alignment of text

Returns

ModHelperText
The created ModHelperText

GameObjectExt.AddText(this GameObject, Info, string, float) Method

Creates a new ModHelperText

public static BTD_Mod_Helper.Api.Components.ModHelperText AddText(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string text, float fontSize);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

text System.String

The text to display

fontSize System.Single

Size of font

Returns

ModHelperText
The created ModHelperText

GameObjectExt.AddText(this GameObject, Info, string) Method

Creates a new ModHelperText

public static BTD_Mod_Helper.Api.Components.ModHelperText AddText(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string text);

Parameters

gameObject UnityEngine.GameObject

info Info

The name/position/size info

text System.String

The text to display

Returns

ModHelperText
The created ModHelperText

GameObjectExt.AddTSMButton(this GameObject, Info, string, string, string) Method

Adds a TSMButton to this with the given buttonId and optional customInputId

public static TSMButton AddTSMButton(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string sprite, string buttonId, string customInputId=null);

Parameters

gameObject UnityEngine.GameObject

this

info Info

Mod Helper Component info

sprite System.String

sprite guid for the button

buttonId System.String

tsm buttonId

customInputId System.String

optional tsm customInputId

Returns

Il2CppAssets.Scripts.Unity.UI_New.InGame.TowerSelectionMenu.TowerSelectionMenuThemes.TSMButton
created TSMButton

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.GetChildren(this GameObject) Method

Gets the direct children of this gameobject

public static System.Collections.Generic.IEnumerable<GameObject> GetChildren(this GameObject gameObject);

Parameters

gameObject UnityEngine.GameObject

this

Returns

System.Collections.Generic.IEnumerable<UnityEngine.GameObject>

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