public static ApplicationListener Get(GameObject go, string listenerTag = null) { ApplicationListener[] listeners = go.GetComponents <ApplicationListener>(); ApplicationListener listener = FindListener(listeners, listenerTag); if (listener == null) { listener = go.AddComponent <ApplicationListener>(); listener.listenerTag = listenerTag; } return(listener); }
private void AddApplicationListener() { Action <LuaTable, bool> luaOnApplicationFocus = m_LuaTable.Get <Action <LuaTable, bool> >("OnApplicationFocus"); Action <LuaTable, bool> luaOnApplicationPause = m_LuaTable.Get <Action <LuaTable, bool> >("OnApplicationPause"); Action <LuaTable> luaOnApplicationQuit = m_LuaTable.Get <Action <LuaTable> >("OnApplicationQuit"); if (luaOnApplicationFocus != null || luaOnApplicationPause != null || luaOnApplicationQuit != null) { ApplicationListener listener = ApplicationListener.Get(this); listener.onApplicationFocus = luaOnApplicationFocus; listener.onApplicationPause = luaOnApplicationPause; listener.onApplicationQuit = luaOnApplicationQuit; if (!m_BehaviourListenerSet.Contains(listener)) { m_BehaviourListenerSet.Add(listener); } } }