SamsonGame/Assets/Sources/unity-ui-extensions-master/Scripts/Utilities/ExtentionMethods.cs

16 lines
389 B
C#
Raw Permalink Normal View History

2021-12-29 20:50:11 +03:00
namespace UnityEngine.UI.Extensions
{
public static class ExtentionMethods
{
public static T GetOrAddComponent<T>(this GameObject child) where T : Component
{
T result = child.GetComponent<T>();
if (result == null)
{
result = child.AddComponent<T>();
}
return result;
}
}
}