Add utils + refacto

This commit is contained in:
2026-01-30 17:39:26 +01:00
parent 9ff17b5305
commit 23d3cb5d2c
29 changed files with 675 additions and 461 deletions
@@ -0,0 +1,47 @@
using UnityEngine;
namespace Unheimlich.Utility
{
public static class UnityExtensions
{
public static void SafeInvoke(this System.Action action)
{
action?.Invoke();
}
public static void SafeInvoke<T>(this System.Action<T> action, T arg)
{
action?.Invoke(arg);
}
public static Color WithAlpha(this Color color, float alpha)
{
color.a = alpha;
return color;
}
public static Vector3 WithY(this Vector3 vector, float y)
{
vector.y = y;
return vector;
}
public static Vector3 WithX(this Vector3 vector, float x)
{
vector.x = x;
return vector;
}
public static Vector3 WithZ(this Vector3 vector, float z)
{
vector.z = z;
return vector;
}
public static void CancelAllTweens(this GameObject gameObject)
{
if (gameObject != null)
LeanTween.cancel(gameObject);
}
}
}