Exemple #1
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        /// <param name="abName">AB包名</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundle(string abName)
        {
            if (!_DicABRelaton.ContainsKey(abName))
            {
                ABRelation abRelationObj = new ABRelation(abName);
                _DicABRelaton.Add(abName, abRelationObj);
            }
            ABRelation tmpABRelationObj = _DicABRelaton[abName];

            //得到指定AB包所有的依赖关系
            string[] strDependenceArray = ABManifestLoader.GetInstance().RetrivalDependence(abName);

            foreach (string item_Dependence in strDependenceArray)
            {
                //添加依赖
                tmpABRelationObj.AddDependence(item_Dependence);

                //添加引用 递归
                yield return(LoadReference(item_Dependence, 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());
            }
        }
Exemple #2
0
        /// <summary>
        /// 加载引用AB包
        /// </summary>
        /// <param name="abName"></param>
        /// <returns></returns>
        private IEnumerator LoadReference(string abName, string refABName)
        {
            //ab依赖包已经加载,依赖包的引用包就是它自己
            if (_DicABRelaton.ContainsKey(abName))
            {
                ABRelation tmpABRelationObj = _DicABRelaton[abName];
                tmpABRelationObj.AddReference(refABName);
            }
            else
            {
                //依赖包未加载,就直接添加引用包,加载依赖包

                ABRelation tmpABRelationObj = new ABRelation(abName);
                tmpABRelationObj.AddReference(refABName);
                _DicABRelaton.Add(abName, tmpABRelationObj);
                //开始加载依赖的包
                yield return(LoadAssetBundle(abName));
            }
        }
        }//Method_end

        /// <summary>
        /// 加载引用AB包
        /// </summary>
        /// <param name="abName">AB包名称</param>
        /// <param name="refABName">被引用AB包名称</param>
        /// <returns></returns>
        private IEnumerator LoadReference(string abName, string refABName)
        {
            //AB包已经加载
            if (_DicABRelation.ContainsKey(abName))
            {
                ABRelation tmpABRelationObj = _DicABRelation[abName];
                //添加AB包引用关系(被依赖)
                tmpABRelationObj.AddReference(refABName);
            }
            else
            {
                ABRelation tmpABRelationObj = new ABRelation(abName);
                tmpABRelationObj.AddReference(refABName);
                _DicABRelation.Add(abName, tmpABRelationObj);

                //开始加载依赖的包(这是一个递归调用)
                yield return(LoadAssetBundeler(abName));
            }
        }