public static EnabledListener Get(GameObject go, string listenerTag = null) { EnabledListener[] listeners = go.GetComponents <EnabledListener>(); EnabledListener listener = FindListener(listeners, listenerTag); if (listener == null) { listener = go.AddComponent <EnabledListener>(); listener.listenerTag = listenerTag; } return(listener); }
private void AddEnabledListener() { Action <LuaTable> luaOnEnable = m_LuaTable.Get <Action <LuaTable> >("OnEnable"); Action <LuaTable> luaOnDisable = m_LuaTable.Get <Action <LuaTable> >("OnDisable"); if (luaOnEnable != null || luaOnDisable != null) { EnabledListener listener = EnabledListener.Get(this); listener.onEnable = luaOnEnable; listener.onDisable = luaOnDisable; if (!m_BehaviourListenerSet.Contains(listener)) { m_BehaviourListenerSet.Add(listener); } } }