Пример #1
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        /// <param name="abName"></param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundle(string abName)
        {
            //AB包关系的建立
            if (!_DicABRelation.ContainsKey(abName))
            {
                ABRelation abRelationObj = new ABRelation(abName);
                _DicABRelation.Add(abName, abRelationObj);
            }
            ABRelation tmpABReltation = _DicABRelation[abName];

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

            //真正加载AB包
            if (_DicSingleABLoaderCache.ContainsKey(abName))
            {
                yield return(_DicSingleABLoaderCache[abName].LoadAssetBundle());
            }
            else
            {
                _CurrentSingleABLoader = new SingleABLoader(abName, CompleteLoadAB);
                _DicSingleABLoaderCache.Add(abName, _CurrentSingleABLoader);
                yield return(_CurrentSingleABLoader.LoadAssetBundle());
            }
        }
 public static ABMainfestLoader GetInstance()
 {
     if (_Instance == null)
     {
         _Instance = new ABMainfestLoader();
     }
     return(_Instance);
 }
Пример #3
0
        /// <summary>
        /// 下载AB指定包
        /// </summary>
        /// <param name="scenesName"></param>
        /// <param name="abName"></param>
        /// <param name="loadAllCompleteHandle">调用是否完成</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundlePack(string scenesName, string abName, DeLoadComplete loadAllCompleteHandle)
        {
            //参数检查
            if (string.IsNullOrEmpty(scenesName) || string.IsNullOrEmpty(abName))
            {
                Debug.LogError("LoadAssetBundlePack方法加载错误,场景名或AB包名称错误");
                yield return(null);
            }
            //等待manifest 清单文件加载完成
            while (!ABMainfestLoader.GetInstance().IsLoadCompleted)
            {
                yield return(null);
            }
            _ManifestObj = ABMainfestLoader.GetInstance().GetABManifest();
            if (_ManifestObj == null)
            {
                Debug.LogError("LoadAssetBundlePack方法加载错误,_ManifestObj为空");
                yield return(null);
            }
            //当前场景加入集合
            if (!_DicAllScenes.ContainsKey(scenesName))
            {
                MultiABMgr multiObj = new MultiABMgr(scenesName, abName, loadAllCompleteHandle);
                _DicAllScenes.Add(scenesName, multiObj);
            }

            //调用下一层  多包管理类
            MultiABMgr tmpMultiObj = _DicAllScenes[scenesName];

            if (tmpMultiObj == null)
            {
                Debug.LogError("LoadAssetBundlePack方法加载错误,tmpMultiObj为空");
            }
            //调用多包管理类  加载指定AB包
            yield return(tmpMultiObj.LoadAssetBundle(abName));
        }
Пример #4
0
 private void Awake()
 {
     //加载清单文件
     StartCoroutine(ABMainfestLoader.GetInstance().LoadMainifestFile());
 }