Пример #1
0
        /// <summary>
        /// 开始切换场景
        /// </summary>
        static IEnumerator StartSwicth()
        {
            m_IsSwitch = true;

            SceneSwitchInfo info = null;
            CallbackReturn <IEnumerator, object> itorCb = null;
            IEnumerator itor = null;

            while (m_SwitchQueue.Count > 0)
            {
                info = m_SwitchQueue.Dequeue();

                itorCb = info.m_ItorCb;
                if (itorCb != null)
                {
                    itor = itorCb(info.m_Data);
                    while (itor.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }

            m_IsSwitch = false;
        }
Пример #2
0
        /// <summary>
        /// 尝试切换场景
        /// </summary>
        /// <param name="itorCb">切换Coroutine</param>
        /// <param name="data">切换时需要的数据</param>
        public static void TrySwitch(CallbackReturn <IEnumerator, object> itorCb, object data)
        {
            if (m_SwitchQueue == null)
            {
                m_SwitchQueue = new Queue <SceneSwitchInfo>();
            }

            SceneSwitchInfo info = new SceneSwitchInfo();

            info.m_ItorCb = itorCb;
            info.m_Data   = data;
            m_SwitchQueue.Enqueue(info);

            if (!m_IsSwitch)
            {
                MainCoroutine.mainCoroutine.StartCoroutine(StartSwicth());
            }
        }