Exemplo n.º 1
0
 //一次清除所有没有引用的bundle
 public void DeleteNoRefBundles()
 {
     for (int i = 0; i < waitingDelBundles.Count; ++i)
     {
         BundleHolder one = waitingDelBundles[i];
         one.Unload();
     }
     waitingDelBundles.Clear();
 }
Exemplo n.º 2
0
        public void RefAsset(string assetPath)
        {
            BundleHolder holder = this.GetExistHolder(assetPath);

            if (null != holder)
            {
                holder.Ref();
            }
        }
Exemplo n.º 3
0
        //直接获取已获得的资源,这种直接设置的情况,只限于它的引用关系已经根据bundle文件添加过了
        //对于程序手动设置的,即在打包的时候并不存在这种依赖关系的,切勿用此接口,注意!!!
        public object GetExistAsset(string assetPath)
        {
            BundleHolder holder = this.GetExistHolder(assetPath);

            if (null != holder)
            {
                return(holder.MyAsset);
            }
            return(null);
        }
Exemplo n.º 4
0
 public void Cancel()
 {
     if (null != loadCouroutine)
     {
         BundleLoader.Ins.StopCoroutine(loadCouroutine);
         loadCouroutine = null;
     }
     holder     = null;
     isFinished = true;
 }
Exemplo n.º 5
0
        //通过asset路径获取asset,cb是在获取后的回调,返回值是一个索引,用于取消获取
        public ulong GetAsset(string assetPath, OnAssetGot cb, bool isManifest = false)
        {
            BundleHolder holder = this.GetHolder(assetPath, isManifest);

            if (null != holder)
            {
                return(holder.RefBy(cb));
            }
            cb(null, 0);
            return(0);
        }
Exemplo n.º 6
0
        public void CancelUngotAsset(ulong cbIdx)
        {
            AssetCallback acb = AssetCallback.Get(cbIdx);

            if (null == acb)
            {
                return;
            }
            BundleHolder holder = GetExistHolder(acb.Path);

            holder?.UnRefBy(cbIdx);
        }
Exemplo n.º 7
0
        public void ReleaseAsset(string assetPath, bool delNow)
        {
            if (null == assetPath)
            {
                return;
            }
            BundleHolder holder = GetExistHolder(assetPath);

            if (null != holder)
            {
                holder.UnRef(delNow);
            }
        }
Exemplo n.º 8
0
        public void ReleaseAsset(string assetPath, bool delNow, int releaseCount = 1)
        {
            if (string.IsNullOrEmpty(assetPath))
            {
                return;
            }
            BundleHolder holder = GetExistHolder(assetPath);

            if (null != holder)
            {
                for (int i = 0; i < releaseCount; ++i)
                {
                    holder.UnRef(delNow);
                }
            }
        }
Exemplo n.º 9
0
        //同步获取asset,记得这样获得的asset需要调用release接口
        public object GetAssetSync(string assetPath)
        {
            BundleHolder holder = this.GetHolder(assetPath, false);

            if (null != holder)
            {
                //暂时不考虑在异步的过程中出现同步加载的请求
                if (holder.IsAsyncLoading())
                {
                    return(null);
                }
                holder.RefSync();
                return(holder.MyAsset);
            }
            return(null);
        }
Exemplo n.º 10
0
 /// <summary>
 /// 获取所有相关的holder,注意并不ref
 /// </summary>
 public void GetAllRelativeHolders(Dictionary <string, BundleHolder> holders)
 {
     if (!holders.ContainsKey(info.path))
     {
         holders[info.path] = this;
     }
     if (null != info.depends)
     {
         for (int i = 0; i < info.depends.Length; ++i)
         {
             BundleHolder holder = mgr.GetHolder(info.depends[i]);
             if (null != holder)
             {
                 holder.GetAllRelativeHolders(holders);
             }
         }
     }
 }
Exemplo n.º 11
0
        //尝试少量的删除
        public IEnumerator TryDelete()
        {
            yield return(null);

            float curTime = Time.realtimeSinceStartup;

            while (waitingDelBundles.Count > ZERO_REF_COUNT)
            {
                BundleHolder one = waitingDelBundles[0];
                if (one.RefCount == 0 && curTime - one.NoRefTime > DEL_TIME)                 //它依赖的holder的时间肯定比它早
                {
                    one.Unload();
                    waitingDelBundles.RemoveAt(0);
                }
                else
                {
                    break;                     //排在前面的时间最久
                }
            }
        }
Exemplo n.º 12
0
 public void AddDelete(BundleHolder holder)
 {
     waitingDelBundles.Add(holder);
 }
Exemplo n.º 13
0
        // TODO ??
        public void RefAsset(string assetPath)
        {
            BundleHolder holder = GetExistHolder(assetPath);

            holder?.Ref();
        }
Exemplo n.º 14
0
        //直接获取已获得的资源,这种直接设置的情况,只限于它的引用关系已经根据bundle文件添加过了
        //对于程序手动设置的,即在打包的时候并不存在这种依赖关系的,切勿用此接口,注意!!!
        public object GetExistAsset(string assetPath)
        {
            BundleHolder holder = this.GetExistHolder(assetPath);

            return(holder?.MyAsset);
        }
Exemplo n.º 15
0
 public BundleLoadTask(BundleHolder _holder, bool _assetSync = true)
 {
     holder    = _holder;
     assetSync = _assetSync;
 }