Skip to Main Content
Table of Contents

BTD_Mod_Helper​.Api​.Components​.ModHelperComponent


BloonsTD6 Mod Helper

BTD_Mod_Helper.Api.Components

ModHelperComponent Class

Base for a helper component for making custom UIs in the same style as Vanilla ones

public class ModHelperComponent

Inheritance UnityEngine.MonoBehaviour  ModHelperComponent

Derived
ModHelperButton
ModHelperCheckbox
ModHelperDropdown
ModHelperImage
ModHelperInputField
ModHelperOption
ModHelperPanel
ModHelperSlider
ModHelperText

Fields

ModHelperComponent.DefaultFontSize Field

Default font size for UI labels

public const float DefaultFontSize = 42;

Field Value

System.Single

ModHelperComponent.DefaultTextAlignment Field

Default alignment for texts and input fields

public const TextAlignmentOptions DefaultTextAlignment = 4098;

Field Value

Il2CppTMPro.TextAlignmentOptions

ModHelperComponent.disableNextFrame Field

Bool for if this should disable itself on the next frame

public bool disableNextFrame;

Field Value

System.Boolean

ModHelperComponent.enableNextFrame Field

Bool for if this should enable itself on the next frame

public bool enableNextFrame;

Field Value

System.Boolean

ModHelperComponent.initialInfo Field

The Info object that this was defined with, determining its initial name, position and size

public Info initialInfo;

Field Value

Info

ModHelperComponent.parent Field

The ModHelperComponent that this is a child of, if any

public ModHelperComponent parent;

Field Value

ModHelperComponent

Properties

ModHelperComponent.LayoutElement Property

The LayoutElement component, if this has been assigned one

public LayoutElement LayoutElement { get; }

Property Value

UnityEngine.UI.LayoutElement

ModHelperComponent.LayoutGroup Property

The LayoutGroup component, if this has been assigned one

public HorizontalOrVerticalLayoutGroup LayoutGroup { get; }

Property Value

UnityEngine.UI.HorizontalOrVerticalLayoutGroup

ModHelperComponent.RectTransform Property

The RectTransform for this GameObject

public RectTransform RectTransform { get; }

Property Value

UnityEngine.RectTransform

Methods

ModHelperComponent.Add(T) Method

Adds another ModHelperComponent as a child of this, returning the child

public T Add<T>(T child)
    where T : BTD_Mod_Helper.Api.Components.ModHelperComponent;

Type parameters

T

Parameters

child T

Returns

T

ModHelperComponent.AddButton(Info, string, Action) Method

Creates a new ModHelperButton

public BTD_Mod_Helper.Api.Components.ModHelperButton AddButton(BTD_Mod_Helper.Api.Components.Info info, string sprite, Action onClick);

Parameters

info Info

The name/position/size info

sprite System.String

The button's visuals

onClick Il2CppSystem.Action

What should happen when the button is clicked

Returns

ModHelperButton

ModHelperComponent.AddCheckbox(Info, bool, string, UnityAction, string, int) Method

Creates a new ModHelperCheckbox

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

Parameters

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

ModHelperComponent.AddCheckbox(Info, bool, string, UnityAction, string) Method

Creates a new ModHelperCheckbox

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

Parameters

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

ModHelperComponent.AddCheckbox(Info, bool, string, UnityAction) Method

Creates a new ModHelperCheckbox

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

Parameters

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

ModHelperComponent.AddCheckbox(Info, bool, string) Method

Creates a new ModHelperCheckbox

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

Parameters

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

ModHelperComponent.AddDropdown(Info, List, float, UnityAction, string, float) Method

Creates a new ModHelperDropdown

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

Parameters

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

ModHelperComponent.AddDropdown(Info, List, float, UnityAction, string) Method

Creates a new ModHelperDropdown

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

Parameters

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

ModHelperComponent.AddDropdown(Info, List, float, UnityAction) Method

Creates a new ModHelperDropdown

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

Parameters

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

ModHelperComponent.AddImage(Info, Sprite) Method

Creates a new ModHelperImage

public BTD_Mod_Helper.Api.Components.ModHelperImage AddImage(BTD_Mod_Helper.Api.Components.Info info, Sprite sprite);

Parameters

info Info

The name/position/size info

sprite UnityEngine.Sprite

The sprite to display

Returns

ModHelperImage
The created ModHelperImage

ModHelperComponent.AddImage(Info, string) Method

Creates a new ModHelperImage

public BTD_Mod_Helper.Api.Components.ModHelperImage AddImage(BTD_Mod_Helper.Api.Components.Info info, string sprite);

Parameters

info Info

The name/position/size info

sprite System.String

The sprite to display

Returns

ModHelperImage
The created ModHelperImage

ModHelperComponent.AddLayoutElement() Method

Adds and returns a LayoutElement for this, making it work as part of a LayoutGroup

public LayoutElement AddLayoutElement();

Returns

UnityEngine.UI.LayoutElement

ModHelperComponent.AddSlider(Info, float, float, float, float, Vector2, UnityAction, float, string, float) Method

Creates a new ModHelperSlider

public BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(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

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

ModHelperComponent.AddSlider(Info, float, float, float, float, Vector2, UnityAction, float, string) Method

Creates a new ModHelperSlider

public BTD_Mod_Helper.Api.Components.ModHelperSlider AddSlider(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

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

ModHelperComponent.AddSlider(Info, float, float, float, float, Vector2, UnityAction, float) Method

Creates a new ModHelperSlider

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

Parameters

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

ModHelperComponent.AddSlider(Info, float, float, float, float, Vector2, UnityAction) Method

Creates a new ModHelperSlider

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

Parameters

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

ModHelperComponent.AddSlider(Info, float, float, float, float, Vector2) Method

Creates a new ModHelperSlider

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

Parameters

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

ModHelperComponent.AddText(Info, string, float, TextAlignmentOptions) Method

Creates a new ModHelperText

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

Parameters

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

ModHelperComponent.AddText(Info, string, float) Method

Creates a new ModHelperText

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

Parameters

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

ModHelperComponent.AddText(Info, string) Method

Creates a new ModHelperText

public BTD_Mod_Helper.Api.Components.ModHelperText AddText(BTD_Mod_Helper.Api.Components.Info info, string text);

Parameters

info Info

The name/position/size info

text System.String

The text to display

Returns

ModHelperText
The created ModHelperText

ModHelperComponent.DeleteObject() Method

Deletes the underlying GameObject this is attached to, not just the component

public void DeleteObject();

ModHelperComponent.GetDescendent(string) Method

Gets a descendent component with the given name

public T GetDescendent<T>(string s="")
    where T : Component;

Type parameters

T

Parameters

s System.String

Returns

T

ModHelperComponent.OnUpdate() Method

Unity Component OnUpdate

protected virtual void OnUpdate();

ModHelperComponent.RemoveComponent() Method

Removes a Component from a GameObject by destroying it

public void RemoveComponent<T>()
    where T : Component;

Type parameters

T

ModHelperComponent.SetActive(bool) Method

Sets whether or not this is active

public void SetActive(bool active);

Parameters

active System.Boolean

ModHelperComponent.SetInfo(Info) Method

Applies the properties of an info struct to this

public void SetInfo(BTD_Mod_Helper.Api.Components.Info newInfo);

Parameters

newInfo Info

ModHelperComponent.SetParent(ModHelperComponent) Method

Sets a particular ModHelperComponent to be the parent of this

public void SetParent(BTD_Mod_Helper.Api.Components.ModHelperComponent newParent);

Parameters

newParent ModHelperComponent

ModHelperComponent.SetParent(Transform) Method

Sets a particular transform to be the parent of this

public void SetParent(Transform newParent);

Parameters

newParent UnityEngine.Transform

Operators

ModHelperComponent.implicit operator GameObject(ModHelperComponent) Operator

Implicitly get the gameObject

public static GameObject implicit operator GameObject(BTD_Mod_Helper.Api.Components.ModHelperComponent component);

Parameters

component ModHelperComponent

Returns

UnityEngine.GameObject

ModHelperComponent.implicit operator RectTransform(ModHelperComponent) Operator

Implicitly get the RectTransform

public static RectTransform implicit operator RectTransform(BTD_Mod_Helper.Api.Components.ModHelperComponent component);

Parameters

component ModHelperComponent

Returns

UnityEngine.RectTransform

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