CTT/Unity/Assets/Hotfix/Logic/Behaviour/Game/Helper/GameObjectHelper.cs

17 lines
339 B
C#

using System;
using System.Collections.Generic;
namespace ET
{
public static class GameObjectHelper
{
#if UNITY
public static K GetOrAddComponent<K>(this UnityEngine.GameObject go)where K:UnityEngine.Component
{
return go.GetComponent<K>() ?? go.AddComponent<K>();
}
#endif
}
}