Esempio n. 1
0
 private void TryLoadSelf()
 {
     if (this.IsLoaded() || null != loadTask)       //有可能出现,因为通过depend的回调有可能先执行到这,然后在StartLoaded执行到这
     {
         return;
     }
     loadTask = new BundleLoadTask(this);
 }
Esempio n. 2
0
        protected void OnAssetSet(bool retry = false)
        {
            loadTask = null;            //清除任务
            bool needRetry = false;

            if (IsLoaded())
            {
                //UObj.DontDestroyOnLoad(asset);//它的删除自己管理
                if (retryTimes > 0)
                {
                    Debugger.LogWarning("{0} times load {1} success", retryTimes, info.path);
                }
            }
            else
            {
                Debugger.LogWarning("warning: {0} asset load null", info.path);
                if (retry && retryTimes <= MAX_RETRY_TIMES)
                {
                    needRetry = true;
                }
            }
            if (needRetry)
            {
                if (null != bundle)
                {
                    bundle.Unload(true);
                    UObj.DestroyImmediate(bundle, true);
                    bundle = null;
                }
                ++retryTimes;
                TryLoadSelf();
            }
            else
            {
                if (null != bundle)
                {
                    if (IsLoaded())
                    {
                        if (IsHoldOneAsset && info.BundleShouldUnload)
                        {
                            BundleLoader.Instance.StartCoroutine(Utils.DelayAction(DelayUnload, 3));
                        }
                    }
                    else
                    {
                        bundle.Unload(true);
                        UObj.DestroyImmediate(bundle, true);
                        bundle = null;
                    }
                }
                isLoading = false;
                OnLoaded();                //如果asset为空,意味着彻底加载失败,通知客户端处理
            }
        }
Esempio n. 3
0
 public void Unload()
 {
     //Debugger.Log("unload bundle {0}",info.path);
     if (this.isLoading)
     {
         if (null != loadTask)
         {
             loadTask.Cancel();
             loadTask = null;
         }
         this.isLoading = false;
     }
     else
     {
         ReleaseAsset();
         if (null != bundle)
         {
             bundle.Unload(true);
             UObj.DestroyImmediate(bundle, true);
             bundle = null;
         }
     }
     mgr.RemoveHolder(info.path);
 }