public static MLuaUIListener Get(GameObject go) { if (!go) { return(null); } MLuaUIListener listener = go.GetComponent <MLuaUIListener>(); if (!listener) { listener = go.AddComponent <MLuaUIListener>(); } return(listener); }
public static void Destroy(GameObject go) { if (!go) { return; } MLuaUIListener listener = go.GetComponent <MLuaUIListener>(); if (listener) { if (Application.isEditor && !Application.isPlaying) { UnityEngine.Object.DestroyImmediate(listener); } else { UnityEngine.Object.Destroy(listener); } } }