コード例 #1
0
        public void LoadAsset(string path, string fileName, CallBackDelegate <object, object> callBack, GetPathFunc getPathFunc, GetDependBundlesFunc getDependenciesFunc, LoadFunc loadAssetFunc, bool externalScene = false)
        {
            string assetBundleName = path + fileName;
            string assetBundlePath = getPathFunc(assetBundleName);
            Bundle bundle          = this.GetBundle(assetBundlePath, true);

            bundle.mExternalScene = externalScene && mIsMobilePlatform;
            if (mBundleLoadTaskList.ContainsKey(bundle))
            {
                mBundleLoadTaskList[bundle].AddParams(fileName, callBack, loadAssetFunc);
                return;
            }
            if (bundle.mLoadCompleted)
            {
                bundle.LoadParams(fileName, callBack, loadAssetFunc);
                return;
            }
            if (mIsMobilePlatform && callBack != null)
            {
                bundle.mPreloadAssetName = fileName;
            }
            Bundle[] dependBundles = this.GetDependBundles(assetBundleName, getPathFunc, getDependenciesFunc);
            bundle.SetDependBundles(dependBundles);
            this.mLoadedBunders[assetBundlePath] = bundle.mBundle;
            LoadTask loadTask = new LoadTask(bundle, dependBundles);

            loadTask.AddParams(fileName, callBack, loadAssetFunc);
            mBundleLoadTaskList[bundle] = loadTask;
            mTask.Insert(0, loadTask);
            //mTask.Add(  loadTask );
            this.StartLoadTask();
        }
コード例 #2
0
        public void Update()
        {
            int taskCount = this.mTask.Count;

            if (taskCount > 0)
            {
                bool     startLoad = false;
                LoadTask l_task    = null;

                for (int i = taskCount - 1; i >= 0; i--)
                {
                    l_task = this.mTask[i];
                    if (l_task.CheckLLoad())
                    {
                        startLoad          = true;
                        this.mCurLoadCount = this.mCurLoadCount - l_task.mLoadCount;

                        this.mBundleLoadTaskList.Remove(l_task.mMainBundle);

                        //以下两行代码顺序不能改
                        this.mTask.Remove(l_task);
                        l_task.LoadComplete();
                    }
                    else
                    {
                        if (startLoad)
                        {
                            this.StartLoadTask();
                        }
                        return;
                    }
                }
                if (startLoad)
                {
                    this.StartLoadTask();
                }
            }
        }