Table of Contents
Extensions for GameObjects
public static class GameObjectExt
Inheritance System.Object GameObjectExt
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
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
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