Esempio n. 1
0
    protected void OnFixedUpdate()
    {
        if (m_currentState == null)
        {
            if (GameResManager.Singleton.m_isPreLoadFinish)
            {//第一个state要等到PreLoad完成
                User.Singleton.OnInit();
                m_nextState = new StateStartup();
            }
        }
        if (null != m_currentState)
        {
            m_currentState.OnFixedUpdate();
            m_widgetManager.FixedUpdate();
        }

        if (null != m_nextState)
        {
            if (null != m_currentState)
            {
                m_currentState.OnExit();
                m_widgetManager.Clear();
                AnyObjectPoolMgr.Singleton.DestroyAll();
                Resources.UnloadUnusedAssets();
                for (int i = 0; i < 100; i++)
                {
                    GC.Collect();
                }
                //GC.WaitForPendingFinalizers();
            }
            m_currentState = m_nextState;
            m_nextState    = null;
            m_currentState.OnEnter();
        }
        GameResManager.Singleton.FixedUpdate();
    }