Example #1
0
        public IEnumerator LoadAssetBundle(string abName)
        {
            Debug.Log("Start load:" + abName);
            //已经加载过直接返回, 执行回调
            if (dicLoadCache.ContainsKey(abName))
            {
                CompleteLoadAB(abName);
                //yield return dicLoadCache[abName].LoadAssetBundle();
            }
            else
            {
                SingleAssetBundleLoader loader = new SingleAssetBundleLoader(abName, CompleteLoadAB);
                dicLoadCache.Add(abName, loader);
                //获取依赖关系
                string[] strDependeceArray = AssetBundleManifestLoader.GetInstance().GetDependce(abName);
                foreach (string item_depend in strDependeceArray)
                {
                    loader.Relation.AddDependence(item_depend);
                    //加载依赖项
                    yield return(LoadDepend(item_depend, loader));
                }

                yield return(loader.LoadAssetBundle());
            }
        }
Example #2
0
        /// <summary>
        /// 加载AssetBundle的方法
        /// </summary>
        /// <param name="abName">要加载AssetBundle的名称</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundle(string abName) {
            // AssetBundle关系的建立
            if (!_relationDict.ContainsKey(abName)) {
                AssetBundleRelation relation = new AssetBundleRelation(abName);
                _relationDict.Add(abName, relation);
            }

            AssetBundleRelation tmpRelation = _relationDict[abName];
            // 获得所有的依赖关系
            string[] depend = AssetBundleManifestLoader.GetInstance().RetrivalDepend(abName);
            foreach (string itemDepend in depend) {
                tmpRelation.AddDepend(itemDepend); // 添加依赖项
                yield return LoadReference(itemDepend, abName); // 添加引用项
            }

            // 进行AssetBundle加载
            if (_loaderCacheDict.ContainsKey(abName)) { // 加载过了
                yield return _loaderCacheDict[abName].LoadABWWW(); // 加载AssetBundle
            }
            else {
                _currSingleAssetBundleLoader = new SingleAssetBundleLoader(abName, CompleteLoadSingle);
                _loaderCacheDict.Add(abName, _currSingleAssetBundleLoader);
                yield return _currSingleAssetBundleLoader.LoadABWWW();
            }

            yield return null;
        }
 private void OnLoadComplete(string abName)
 {
     loader.DisposeAll();
     loader1 = new SingleAssetBundleLoader(abName, OnLoadComplete1);
     StartCoroutine(loader1.LoadAssetBundle());
 }
 void Start()
 {
     loader = new SingleAssetBundleLoader(abName, OnLoadComplete);
     StartCoroutine(loader.LoadAssetBundle());
 }
Example #5
0
 /// <summary>
 /// 加载依赖包,并添加到引用
 /// </summary>
 /// <param name="loadName">要加载的包</param>
 /// <param name="refName">引用他的包</param>
 /// <returns></returns>
 public IEnumerator LoadDepend(string loadName, SingleAssetBundleLoader refABLoader)
 {
     refABLoader.Relation.AddReference(loadName);
     yield return(LoadAssetBundle(loadName));
 }