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
Default font size for UI labels
public const float DefaultFontSize = 42;
Default alignment for texts and input fields
public const TextAlignmentOptions DefaultTextAlignment = 4098;
Il2CppTMPro.TextAlignmentOptions
Bool for if this should disable itself on the next frame
public bool disableNextFrame;
Bool for if this should enable itself on the next frame
public bool enableNextFrame;
The Info object that this was defined with, determining its initial name, position and size
public Info initialInfo;
The ModHelperComponent that this is a child of, if any
public ModHelperComponent parent;
The LayoutElement component, if this has been assigned one
public LayoutElement LayoutElement { get; }
The LayoutGroup component, if this has been assigned one
public HorizontalOrVerticalLayoutGroup LayoutGroup { get; }
UnityEngine.UI.HorizontalOrVerticalLayoutGroup
The RectTransform for this GameObject
public RectTransform RectTransform { get; }
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;
T
child T
Creates a new ModHelperButton
public BTD_Mod_Helper.Api.Components.ModHelperButton AddButton(BTD_Mod_Helper.Api.Components.Info info, string sprite, Action onClick);
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
Creates a new ModHelperCheckbox
public BTD_Mod_Helper.Api.Components.ModHelperCheckbox AddCheckbox(BTD_Mod_Helper.Api.Components.Info info, bool defaultValue, string background);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperDropdown
The created ModHelperDropdown
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);
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
ModHelperDropdown
The created ModHelperDropdown
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);
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
ModHelperDropdown
The created ModHelperDropdown
Creates a new ModHelperImage
public BTD_Mod_Helper.Api.Components.ModHelperImage AddImage(BTD_Mod_Helper.Api.Components.Info info, Sprite sprite);
info Info
The name/position/size info
sprite UnityEngine.Sprite
The sprite to display
ModHelperImage
The created ModHelperImage
Creates a new ModHelperImage
public BTD_Mod_Helper.Api.Components.ModHelperImage AddImage(BTD_Mod_Helper.Api.Components.Info info, string sprite);
info Info
The name/position/size info
sprite System.String
The sprite to display
ModHelperImage
The created ModHelperImage
Adds and returns a LayoutElement for this, making it work as part of a LayoutGroup
public LayoutElement AddLayoutElement();
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);
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
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);
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
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);
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
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);
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. "%"
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);
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
Creates a new ModHelperText
public BTD_Mod_Helper.Api.Components.ModHelperText AddText(BTD_Mod_Helper.Api.Components.Info info, string text);
info Info
The name/position/size info
text System.String
The text to display
ModHelperText
The created ModHelperText
Creates a new ModHelperText
public BTD_Mod_Helper.Api.Components.ModHelperText AddText(BTD_Mod_Helper.Api.Components.Info info, string text, float fontSize);
info Info
The name/position/size info
text System.String
The text to display
fontSize System.Single
Size of font
ModHelperText
The created ModHelperText
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);
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
ModHelperText
The created ModHelperText
Deletes the underlying GameObject this is attached to, not just the component
public void DeleteObject();
Gets a descendent component with the given name
public T GetDescendent<T>(string s="")
where T : Component;
T
Unity Component Update
protected virtual void OnUpdate();
Removes a Component from a GameObject by destroying it
public void RemoveComponent<T>()
where T : Component;
T
Sets whether or not this is active
public void SetActive(bool active);
active System.Boolean
Applies the properties of an info struct to this
public void SetInfo(BTD_Mod_Helper.Api.Components.Info newInfo);
newInfo Info
Sets a particular ModHelperComponent to be the parent of this
public void SetParent(BTD_Mod_Helper.Api.Components.ModHelperComponent newParent);
newParent ModHelperComponent
Sets a particular transform to be the parent of this
public void SetParent(Transform newParent);
newParent UnityEngine.Transform
Implicitly get the gameObject
public static GameObject implicit operator GameObject(BTD_Mod_Helper.Api.Components.ModHelperComponent component);
component ModHelperComponent
Implicitly get the RectTransform
public static RectTransform implicit operator RectTransform(BTD_Mod_Helper.Api.Components.ModHelperComponent component);
component ModHelperComponent