コード例 #1
0
        /// <summary>
        /// 加载下一个
        /// </summary>
        private void LoadNext()
        {
            if (null != m_LoaderInfo)
            {
                loaderTask.ReleaseLoader(m_LoaderInfo.loader);
                m_LoaderInfo = null;
            }

            if (m_ListLoaderInfos.Count == 0)
            {
                isFinish = true;
                return;
            }

            m_LoaderInfo = m_ListLoaderInfos[0];
            m_ListLoaderInfos.RemoveAt(0);

            switch (m_LoaderInfo.loader.state)
            {
            case LoaderState.None:
                PushCallback();
                m_LoaderInfo.loader.Start();
                break;

            case LoaderState.Loading:
                PushCallback();
                break;

            case LoaderState.Complete:
                LoadCompleted(m_LoaderInfo, m_LoaderInfo.loader.data);
                LoadNext();
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// 重置
        /// </summary>
        public void Reset()
        {
            isFinish  = false;
            isLoading = false;

            m_LoaderInfo = null;
        }
コード例 #3
0
        /// <summary>
        /// 加载完成
        /// </summary>
        /// <param name="info">加载器信息</param>
        /// <param name="data">加载结果</param>
        private void LoadCompleted(LoaderInfo info, object data)
        {
            if (info == null)
            {
                return;
            }

            info.completeCallback?.Invoke(this, data);
        }
コード例 #4
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="path">路径</param>
        /// <param name="param">附加参数</param>
        /// <param name="completeCallback">回调</param>
        /// <param name="async">异步</param>
        /// <param name="insert">插队</param>
        public void Add(LoaderType type, string path, object param, LoaderGroupCompleteCallback completeCallback,
                        bool async, bool insert)
        {
            LoaderInfo loaderInfo = new LoaderInfo
            {
                loader           = loaderTask.GetLoader(type, path, param, async),
                completeCallback = completeCallback
            };

            if (insert)
            {
                m_ListLoaderInfos.Insert(0, loaderInfo);
            }
            else
            {
                m_ListLoaderInfos.Add(loaderInfo);
            }

            if (isLoading && isFinish)
            {
                isFinish = false;
                LoadNext();
            }
        }