Exemple #1
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        /// <param name="abName">AssetBundle 名称</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundeler(string abName)
        {
            //AB包关系的建立
            if (!_DicABRelation.ContainsKey(abName))
            {
                ABRelation abRelationObj = new ABRelation(abName);
                _DicABRelation.Add(abName, abRelationObj);
            }
            ABRelation tmpABRelationObj = _DicABRelation[abName];

            //得到指定AB包所有的依赖关系(查询Manifest清单文件)
            string[] strDependeceArray = ABManifestLoader.GetInstance().RetrivalDependce(abName);
            foreach (string item_Depence in strDependeceArray)
            {
                //添加“依赖”项
                tmpABRelationObj.AddDependence(item_Depence);
                //添加“引用”项    (递归调用)
                yield return(LoadReference(item_Depence, abName));
            }

            //真正加载AB包
            if (_DicSingleABLoaderCache.ContainsKey(abName))
            {
                yield return(_DicSingleABLoaderCache[abName].LoadAssetBundle());
            }
            else
            {
                _CurrentSinglgABLoader = new SingleABLoader(abName, CompleteLoadAB);
                _DicSingleABLoaderCache.Add(abName, _CurrentSinglgABLoader);
                yield return(_CurrentSinglgABLoader.LoadAssetBundle());
            }
        }//Method_end
Exemple #2
0
        /// <summary>
        /// 下载AssetBundel 指定包
        /// </summary>
        /// <param name="scenesName">场景名称</param>
        /// <param name="abName">AssetBundle 包名称</param>
        /// <param name="loadAllCompleteHandle">委托: 调用是否完成</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundlePack(string scenesName, string abName, DelLoadComplete loadAllCompleteHandle)
        {
            //参数检查
            if (string.IsNullOrEmpty(scenesName) || string.IsNullOrEmpty(abName))
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePack()/ScenesName Or abName is null ,请检查!");
                yield return(null);
            }

            //等待Manifest清单文件加载完成
            while (!ABManifestLoader.GetInstance().IsLoadFinish)
            {
                yield return(null);
            }
            _ManifestObj = ABManifestLoader.GetInstance().GetABManifest();
            if (_ManifestObj == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePack()/_ManifestObj is null ,请先确保加载Manifest清单文件!");
                yield return(null);
            }

            //把当前场景加入集合中。
            if (!_DicAllScenes.ContainsKey(scenesName))
            {
                MultiABMgr multiMgrObj = new MultiABMgr(scenesName, abName, loadAllCompleteHandle);
                _DicAllScenes.Add(scenesName, multiMgrObj);
            }

            //调用下一层(“多包管理类”)
            MultiABMgr tmpMultiMgrObj = _DicAllScenes[scenesName];

            if (tmpMultiMgrObj == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePack()/tmpMultiMgrObj is null ,请检查!");
            }
            //调用“多包管理类”的加载指定AB包。
            yield return(tmpMultiMgrObj.LoadAssetBundeler(abName));
        }//Method_end
Exemple #3
0
 void Awake()
 {
     //加载Manifest清单文件
     StartCoroutine(ABManifestLoader.GetInstance().LoadMainifestFile());
 }