Ejemplo n.º 1
0
        public void Release(bool destroy = false)
        {
            if (m_queue != null)
            {
                m_queue.Clear();
            }

            m_loadedCount       = 0;
            m_totalProgress     = 0;
            m_totalCurrProgress = 0f;
            m_onComplete        = null;
            m_onProgress        = null;
            m_assetsMgr         = null;

            if (destroy)
            {
                _instance = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <param name="obj"></param>
        /// <param name="arg"></param>
        private void OnComplete(string path, string name, UnityEngine.Object obj, params string[] args)
        {
            m_loadedCount++;

            if (m_loadedCount == m_totalProgress)
            {
                m_totalProgress     = 0;
                m_totalCurrProgress = 0;
                m_onComplete();
                m_onComplete = null;
                m_onProgress = null;

                foreach (var item in m_queue)
                {
                    item.Value.Release();
                }

                m_queue.Clear();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 提前预加载的所有资源,都需要由提供加载列表的指定脚本调用资源管理器的DiscardUsage销毁
        /// </summary>
        /// <param name="list"></param>
        /// <param name="onComplete">全部完成回调</param>
        /// <param name="onProgress">总进度</param>
        public void Load(List <TaskDesc> list, Action onComplete, TaskLoadingProgress onProgress = null)
        {
            if (list.Count < 1)
            {
                return;
            }

            if (m_queue == null)
            {
                m_queue = new Dictionary <string, TaskDesc>();
            }

            m_onComplete  = onComplete;
            m_onProgress  = onProgress;
            m_loadedCount = 0;

            LoadingProgressCallback t_progress = null;

            if (onProgress != null)
            {
                t_progress = OnProgress;
            }

            UnityEngine.Object t_obj = null;

            foreach (var item in list)
            {
                if (!m_assetsMgr.GetResource(item.script, item.path, item.name, item.instance, item.type, out t_obj))
                {
                    m_queue.Add(item.path, item);
                    m_assetsMgr.GetResource(item.script, item.path, item.name, t_progress, OnComplete, item.type, item.instance, item.isCache, item.args);
                }
            }

            m_totalProgress = m_queue.Count;
            list.Clear();
        }