Skip to content

TPExtensionsPackage

Tomasz Piowczyk edited this page Sep 14, 2018 · 8 revisions

You can see core wiki THERE

Attributes

public class TPEditorAttribute : PropertyAttribute { }

public class TPCallbackAttribute : TPEditorAttribute { public string CallbackName { get; } }

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class InspectorReadOnlyAttribute(){}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class InspectorBackgroundAttribute(float r, float g, float b, float a = 1){}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class RequiredAttriubte(string message = null){}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class OnValueChangedAttribute(string callbackName){}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class InspectorValidateAttribute(string callbackName, string message = null){}

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ButtonAttriubte(string buttonName = null){}

// boolStatementsString can be public/private/serializable:
// - Method that returns bool or UnityEngine.Object,
// - Variable that returns bool or UnityEngine.Object,
// You can put multiple conditions splitted with ',' character - treated as "AND"
// Examples:
// [SerializeField] private bool myBool, myOtherBool
// private bool GetBool() => myOtherBool && myBool
// [InspectorHide("GetBool")] private int integer; // will be drawed when myBool and myOther are true
// [InspectorHide("myBool, myOtherBool")] private string text; // will be drawed when myBool AND myOther
[AttributeUsage(AttributeTargets.Field, Inherited = true)]
public class InspectorHideAttribute(string boolStatementsString, bool disableOnly = false){}

TPExtensions (GameObject)

public static GameObject FindObjectWithLayer(this Object obj, int layer){}

TPExtensions (UI)

public static void SetSprite(this Image image, Sprite sprite){}
public static void SetFill(this Image image, float fillAmount){}
public static void SetAlpha(this Image image, float alpha){}

public static void SetValue(this Slider slider, float value){}

public static bool IsInside(this Rect thisRect, Rect rect){}

public static void ClampToWindow(this RectTransform panelRectTransform, RectTransform parentRectTransform){}

TPExtensions (String)

/// resolutionText should be formatted as: "320 x 200 @ 60Hz" or "320 x 200"
public static Resolution ToResolution(this string resolutionText){}
public static string ToStringWithoutHZ(this Resolution resolution){}
public static string[] ToStringWithoutHZ(this Resolution[] resolutions){}
public static string[] ToStringWithHZ(this Resolution[] resolutions){}

TPExtensions (Utility)

public static bool IsFrame(this int frameModulo){}

public static void ToLog(this object obj, string label = null){}
public static void AllToLog(this object[] objs, string label = null){}

public static float GetFloat(this AudioMixer audioMixer, string paramName){}

TPExtensions (Transform)

public static T[] GetComponentsOnlyInChildren<T>(this GameObject gameObject){}
public static T GetComponentOnlyInChildren<T>(this GameObject gameObject){}
public static void DestroyChildren(this Transform transform){}

public static void SetPosX(this Transform transform, float x){}
public static void SetPosY(this Transform transform, float y){}
public static void SetPosZ(this Transform transform, float z){}

public static Vector3[] GetChildrenPositions(this Transform parent){}
public static Transform[] GetChilds(this Transform parent){}

TPExtensions (Vector)

public static Vector3[] SequenceSquarePositions(int width, int height){}
public static Vector3[] SequenceBoxPositions(int width, int height, int layers){}

public static Vector3 Set(this Vector3 vector, float equal){}
public static Vector3 Set(this Vector2 vector, float equal){}

public static Vector3 Add(this Vector3 vector, float addition){}
public static Vector2 Add(this Vector2 vector, float addition){}

public static Vector3 Subtraction(this Vector3 vector, float subtraction){}
public static Vector2 Subtraction(this Vector2 vector, float subtraction){}

public static bool IsGreaterEqualThan(this Vector2 vector, Vector3 equalVector){}
public static bool IsGreaterEqualThan(this Vector3 vector, Vector2 equalVector){}
public static bool IsGreaterEqualThan(this Vector3 vector, Vector3 equalVector){}

public static bool IsLessEqualThan(this Vector2 vector, Vector3 equalVector){}
public static bool IsLessEqualThan(this Vector3 vector, Vector2 equalVector){}
public static bool IsLessEqualThan(this Vector3 vector, Vector3 equalVector){}

public static bool IsLessThan(this Vector2 vector, Vector3 equalVector){}
public static bool IsLessThan(this Vector2 vector, Vector3 equalVector){}
public static bool IsLessThan(this Vector3 vector, Vector2 equalVector){}
public static bool IsLessThan(this Vector3 vector, Vector3 equalVector){}

public static bool IsGreaterThan(this Vector2 vector, Vector3 equalVector){}
public static bool IsGreaterThan(this Vector3 vector, Vector2 equalVector){}
public static bool IsGreaterThan(this Vector3 vector, Vector3 equalVector){}

public static bool IsEqualTo(this Vector2 vector, Vector3 equalVector){}
public static bool IsEqualTo(this Vector3 vector, Vector2 equalVector){}
public static bool IsEqualTo(this Vector3 vector, Vector3 equalVector){}

TPExtensions (Editor)

public static object GetTargetObject(this SerializedProperty prop){}
public static bool HasAnyElementSameValue(this SerializedProperty array, SerializedProperty key1, int skipIndex, Type castType = null){}
public static object GetValue(this SerializedProperty prop){}

Clone this wiki locally