Пример #1
0
        internal AssetBundleLoader CreateLoader(string abFileName, string oriName = null)
        {
            AssetBundleLoader loader = null;

            if (_loaderCache.ContainsKey(abFileName))
            {
                loader = _loaderCache[abFileName];
            }
            else
            {
#if _AB_MODE_
                AssetBundleData data = _depInfoReader.GetAssetBundleInfo(abFileName);
                if (data == null && oriName != null)
                {
                    data = _depInfoReader.GetAssetBundleInfo(oriName.ToLower());//todo: ab search path
                    if (data != null && _loaderCache.ContainsKey(data.bundleName))
                    {
                        return _loaderCache[data.bundleName];
                    }
                }
                if (data == null)
                {
                    MissAssetBundleLoader missLoader = new MissAssetBundleLoader();
                    missLoader.bundleManager = this;
                    return missLoader;
                }

                loader = this.CreateLoader();
                loader.bundleManager = this;
                loader.bundleData = data;
                loader.bundleName = data.bundleName;
#else
                loader = this.CreateLoader();
                loader.bundleManager = this;
                loader.bundleName = abFileName;
#endif
                _loaderCache[abFileName] = loader;
            }

            return loader;
        }
Пример #2
0
        public AssetBundleLoader Load(string path, LoadAssetCompleteHandler handler = null)
        {
#if _AB_MODE_
            AssetBundleLoader loader = this.CreateLoader(HashUtil.Get(path.ToLower()) + ".ab", path);
#else
            AssetBundleLoader loader = this.CreateLoader(path);
#endif
            if (loader == null)
            {
                handler(null);
            }
            else
            {
                _thisTimeLoaderSet.Add(loader);
                if (loader.isComplete)
                {
                    if (handler != null)
                    {
                        handler(loader.bundleInfo);
                    }
                }
                else
                {
                    if (handler != null)
                    {
                        loader.onComplete += handler;
                    }
                    _isCurrentLoading = true;

                    if (loader.state < LoadState.State_Loading)
                    {
                        _nonCompleteLoaderSet.Add(loader);
                    }
                    this.StartLoad();
                }
            }
            return(loader);
        }
Пример #3
0
        void LoadDepends()
        {
            if (depLoaders == null)
            {
                depLoaders = new AssetBundleLoader[bundleData.dependencies.Length];
                for (int i = 0; i < bundleData.dependencies.Length; i++)
                {
                    depLoaders[i] = bundleManager.CreateLoader(bundleData.dependencies[i]);
                }
            }

            _currentLoadingDepCount = 0;
            for (int i = 0; i < depLoaders.Length; i++)
            {
                AssetBundleLoader depLoader = depLoaders[i];
                if (depLoader.state != LoadState.State_Error && depLoader.state != LoadState.State_Complete)
                {
                    _currentLoadingDepCount++;
                    depLoader.onComplete += OnDepComplete;
                    depLoader.Load();
                }
            }
            this.CheckDepComplete();
        }
Пример #4
0
 internal void LoadError(AssetBundleLoader loader)
 {
     Debug.LogWarning("Cant load AB : " + loader.bundleName, this);
     LoadComplete(loader);
 }
Пример #5
0
 internal void LoadError(AssetBundleLoader loader)
 {
     this.LoadComplete(loader);
 }
Пример #6
0
 /// <summary>
 /// 请求加载Bundle,这里统一分配加载时机,防止加载太卡
 /// </summary>
 /// <param name="loader"></param>
 internal void Enqueue(AssetBundleLoader loader)
 {
     if (_requestRemain < 0)
         _requestRemain = 0;
     _requestQueue.Add(loader);
 }