Beispiel #1
0
        /// <summary>
        /// 加载
        /// </summary>
        static private ResRef LoadResByUrl <T>(string url, string resName, ResLoadCompleteDelegate onComplete, IResDesc resDesc, bool holdbundle = false) where T : ResBase, new()
        {
            // 查找
            var res = FindRes(url);

            if (null == res)
            {
                res = new T();
                res.Init(url, resName, holdbundle);
            }
            else
            {
                // 从空闲列表移除
                if (res.refCount <= 0)
                {
                    _unusedResources.Remove(res);
                }

                if (res.isLoaded)
                {
                    var Ref = ResRef.Create(res, onComplete, resDesc);
                    Ref.OnComplete();
                    return(Ref);
                }
            }

            var r = ResRef.Create(res, onComplete, resDesc);

            // 加入列表
            _loader.Push(r);
            return(r);
        }
Beispiel #2
0
        /// <summary>
        /// 添加回调(空资源引用)
        /// </summary>
        /// <param name="onComplete"></param>
        /// <returns></returns>
        static public ResRef PushDelegate(ResLoadCompleteDelegate onComplete)
        {
            var r = ResRef.Create(null, onComplete, null);

            if (r.res == null)
            {
                r.OnComplete();
            }
            else
            {
                _loader.Push(r);
            }
            // 重置进度
            _loader.ResetProgress();

            return(r);
        }