zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Hotfix/Logic/Behaviour/Game/Helper/GameObjectHelper.cs

14 lines
313 B
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections.Generic;
namespace ET
{
public static class GameObjectHelper
{
public static K GetOrAddComponent<K>(this UnityEngine.GameObject go)where K:UnityEngine.Component
{
return go.GetComponent<K>() ?? go.AddComponent<K>();
}
}
}