Extensions for GameObjects
public static class GameObjectExt
Inheritance System.Object GameObjectExt
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);
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
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperCheckbox
The new ModHelperCheckbox
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);
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
ModHelperDropdown
The created ModHelperDropdown
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);
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
ModHelperDropdown
The created ModHelperDropdown
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);
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
ModHelperDropdown
The created ModHelperDropdown
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);
gameObject UnityEngine.GameObject
info Info
The name/position/size info
sprite UnityEngine.Sprite
The sprite to display
ModHelperImage
The created ModHelperImage
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);
gameObject UnityEngine.GameObject
info Info
The name/position/size info
sprite System.String
The sprite to display
ModHelperImage
The created ModHelperImage
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;
T
gameObject UnityEngine.GameObject
modHelperComponent T
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);
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
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);
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. "%"
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);
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
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);
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
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);
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
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);
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
ModHelperText
The created ModHelperText
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);
gameObject UnityEngine.GameObject
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 static BTD_Mod_Helper.Api.Components.ModHelperText AddText(this GameObject gameObject, BTD_Mod_Helper.Api.Components.Info info, string text);
gameObject UnityEngine.GameObject
info Info
The name/position/size info
text System.String
The text to display
ModHelperText
The created ModHelperText
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);
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
Il2CppAssets.Scripts.Unity.UI_New.InGame.TowerSelectionMenu.TowerSelectionMenuThemes.TSMButton
created TSMButton
Destroys this GameObject
public static void Destroy(this GameObject gameObject);
gameObject UnityEngine.GameObject
Destroys all children of a game object
public static void DestroyAllChildren(this GameObject gameObject);
gameObject UnityEngine.GameObject
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;
T
gameObject T
parent UnityEngine.Transform
Instantiate a clone of the GameObject keeping the same parent
public static T Duplicate<T>(this T gameObject)
where T : Object;
T
gameObject T
Used to null check unity objects without bypassing the lifecycle
public static bool Exists<T>(this T obj, out T result)
where T : Object;
T
obj T
result T
Used to null check unity objects without bypassing the lifecycle
public static T Exists<T>(this T obj)
where T : Object;
T
obj T
Gets the direct children of this gameobject
public static System.Collections.Generic.IEnumerable<GameObject> GetChildren(this GameObject gameObject);
gameObject UnityEngine.GameObject
this
System.Collections.Generic.IEnumerable<UnityEngine.GameObject>
Finds a component with the given path and type
public static T GetComponent<T>(this GameObject gameObject, string componentPath);
T
gameObject UnityEngine.GameObject
componentPath System.String
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;
T
gameObject UnityEngine.GameObject
componentName System.String
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;
T
gameObject UnityEngine.GameObject
component T
Returns whether a component of the given type exists on a game object
public static bool HasComponent<T>(this GameObject gameObject)
where T : Component;
T
gameObject UnityEngine.GameObject
Makes the Game Object hidden (not visible) by setting the scale to zero
public static void Hide(this GameObject gameObject);
gameObject UnityEngine.GameObject
Logs a GameObject's hierarchy recursively
public static void RecursivelyLog(this GameObject gameObject, int depth=0);
gameObject UnityEngine.GameObject
depth System.Int32
Removes a Component from a GameObject by destroying it
public static void RemoveComponent<T>(this GameObject gameObject)
where T : Component;
T
gameObject UnityEngine.GameObject
Makes the Game Object visible by setting the scale to the default value of 1
public static void Show(this GameObject gameObject);
gameObject UnityEngine.GameObject
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);
gameObject UnityEngine.GameObject
translation UnityEngine.Vector3