Files
XMen/Assets/Plugins/XPlugins/XUI/UIStack/GameObjectExtension.cs
2025-07-02 17:56:55 +08:00

13 lines
250 B
C#

using UnityEngine;
public static class GameObjectExtension {
public static T GetOrAddComponent<T>(this GameObject g) where T : Component {
T ret = g.GetComponent<T>();
if (ret == null) {
ret = g.AddComponent<T>();
}
return ret;
}
}