示例#1
0
 public BundleLoadTask(BundleHolder _holder, bool _assetSync = true)
 {
     holder         = _holder;
     assetSync      = _assetSync;
     loadCouroutine = Run();
     BundleLoader.Instance.StartCoroutine(loadCouroutine);
 }
示例#2
0
        public void NoDelete(BundleHolder holder)
        {
            int index = waitingDelBundles.IndexOf(holder);

            if (index >= 0)
            {
                waitingDelBundles.RemoveAt(index);
            }
        }
示例#3
0
 //一次清除所有没有引用的bundle
 public void DeleteNoRefBundles()
 {
     for (int i = 0; i < waitingDelBundles.Count; ++i)
     {
         BundleHolder one = waitingDelBundles[i];
         one.Unload();
     }
     waitingDelBundles.Clear();
 }
示例#4
0
        public void RefAsset(string assetPath)
        {
            BundleHolder holder = this.GetExistHolder(assetPath);

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

            if (null != holder)
            {
                return(holder.MyAsset);
            }
            return(null);
        }
示例#7
0
        public void ReleaseAsset(string assetPath, bool delNow, int releasCount)
        {
            BundleHolder holder = GetExistHolder(assetPath);

            if (null != holder)
            {
                for (int i = 0; i < releasCount; ++i)
                {
                    holder.UnRef(delNow);
                }
            }
        }
示例#8
0
        public void ReleaseAsset(string assetPath, bool delNow)
        {
            if (null == assetPath)
            {
                return;
            }
            BundleHolder holder = GetExistHolder(assetPath);

            if (null != holder)
            {
                holder.UnRef(delNow);
            }
        }
示例#9
0
        public UObj GetAssetSync(string assetPath)
        {
            BundleHolder holder = this.GetHolder(assetPath, false);

            if (null != holder)
            {
                if (!holder.IsLoaded())
                {
                    holder.LoadSync();
                }
                return(holder.MyAsset);
            }
            return(null);
        }
示例#10
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));
            }
            else
            {
                cb(null, 0);
            }
            return(0);
        }
示例#11
0
        public void CancelUngotAsset(ulong cbIdx)
        {
            AssetCallback acb = AssetCallback.Get(cbIdx);

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

            if (null != holder)
            {
                holder.UnRefBy(cbIdx);
            }
        }
示例#12
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);
             }
         }
     }
 }
示例#13
0
 //获得holder
 public BundleHolder GetHolder(string bundlePath, bool isManifest = false)
 {
     if (bundles.ContainsKey(bundlePath))
     {
         return(bundles[bundlePath]);
     }
     else
     {
         BundleInfo bi = depMap.GetInfo(bundlePath, isManifest);
         if (null != bi)
         {
             BundleHolder holder = BundleHolder.Gen(bi, this);
             bundles.Add(bundlePath, holder);
             return(holder);
         }
         else
         {
             return(null);
         }
     }
 }
示例#14
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;                    //排在前面的时间最久
                }
            }
            //_Scripts.Main.App.Log(string.Format("bundle count = {0}",bundles.Count));
        }
示例#15
0
 public void AddDelete(BundleHolder holder)
 {
     waitingDelBundles.Add(holder);
 }