예제 #1
0
 public void Unload()
 {
     if (AppEnv.ResVerbose)
     {
         this.Msg($"unload bundle {PathIdProfile.Ins.GetPath(info.path)}");
     }
     if (this.isLoading)
     {
         if (null != loadTask)
         {
             loadTask.Cancel();
             loadTask = null;
         }
         this.isLoading = false;
     }
     else
     {
         ReleaseAsset();
         if (null != bundle)
         {
             if (AppEnv.ResVerbose)
             {
                 this.Msg($"bundle unloaded:{PathIdProfile.Ins.GetPath(info.path)}");
             }
             bundle.Unload(true);
             bundle = null;
         }
     }
     mgr.RemoveHolder(info.path);
 }
예제 #2
0
 private void RunTask(BundleLoadTask task)
 {
     if (null != task)
     {
         task.Start();
         ++runningCount;
         runningTasks.Add(task);
     }
 }
예제 #3
0
 private void TryLoadSelf()
 {
     if (this.IsLoaded() || null != loadTask || null == BundleLoader.Ins)     //有可能出现,因为通过depend的回调有可能先执行到这,然后在StartLoaded执行到这
     {
         return;
     }
     loadTask = new BundleLoadTask(this);
     BundleLoader.Ins.StartLoadTask(loadTask);
 }
예제 #4
0
        protected void OnAssetSet(bool retry = false)
        {
            loadTask = null;            //清除任务
            bool needRetry = false;

            if (IsLoaded())
            {
                //UObj.DontDestroyOnLoad(asset);//它的删除自己管理
                if (retryTimes > 0)
                {
                    this.Warning($"{retryTimes} times load {info.path} success");
                }
            }
            else
            {
                this.Warning($"warning: {info.path} asset load null");
                if (retry && retryTimes <= MAX_RETRY_TIMES)
                {
                    needRetry = true;
                }
            }
            if (needRetry)
            {
                if (null != bundle)
                {
                    this.Warning($"warning: {info.path} bundle release cause retry fail");
                    bundle.Unload(true);
                    bundle = null;
                }
                ++retryTimes;
                TryLoadSelf();
            }
            else
            {
                if (null != bundle)
                {
                    if (!IsLoaded())
                    {
                        this.Warning($"warning: {info.path} bundle unload cause asset no use");
                        bundle.Unload(true);
                        bundle = null;
                    }
                }
                isLoading = false;
                OnLoaded();
            }
        }
예제 #5
0
        private void CheckRunning()
        {
            for (int i = 0; i < runningCount;)
            {
                BundleLoadTask task = runningTasks[i];
                if (task.IsFinished)
                {
                    runningTasks.RemoveAt(i);
                    --runningCount;
                }
                else
                {
                    ++i;
                }
            }

            while (waitingTasks.Count > 0 && runningCount < BUNDLE_TASK_MAX)
            {
                RunTask(waitingTasks.Dequeue());
            }
        }
예제 #6
0
 public void StartLoadTask(BundleLoadTask task)
 {
     waitingTasks.Enqueue(task);
 }