예제 #1
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        /// <param name="abName">AB包包名</param>
        public IEnumerator LoadAB(string abName, LoadAssetFromWhere where = LoadAssetFromWhere.OnLine)
        {
            ABRelation rela;

            //建立AB包关系
            if (!_abRelation.ContainsKey(abName))
            {
                rela = new ABRelation(abName);
                _abRelation.Add(abName, rela);
            }
            rela = _abRelation[abName];

            //获取AB包的所有依赖关系
            string[] dependeceArr = ABManifestLoader.Instance.GetDependce(abName);
            foreach (var cell in dependeceArr)
            {
                //添加依赖项
                rela.AddDependence(cell);
                //加载引用项
                yield return(LoadReference(cell, abName, where));
            }

            //加载AB包
            if (_singleABLoaderCache.ContainsKey(abName))
            {
                yield return(_singleABLoaderCache[abName].LoadAB());
            }
            else
            {
                _currentSingleABLoader = new SingleAssetBundleLoader(abName, CompleteLoadAB, where);
                _singleABLoaderCache.Add(abName, _currentSingleABLoader);
                yield return(_currentSingleABLoader.LoadAB());
            }
            yield return(null);
        }
예제 #2
0
        /// <summary>
        /// 加载引用AB包
        /// </summary>
        IEnumerator LoadReference(string abName, string refName, LoadAssetFromWhere where)
        {
            ABRelation tmpABRelation;

            if (_abRelation.ContainsKey(abName))
            {
                tmpABRelation = _abRelation[abName];
                //添加AB包引用关系(被依赖)
                tmpABRelation.AddReference(refName);
            }
            else
            {
                tmpABRelation = new ABRelation(abName);
                tmpABRelation.AddReference(refName);
                _abRelation.Add(abName, tmpABRelation);

                //开始加载依赖包(递归)
                yield return(LoadAB(abName, where));
            }

            yield return(null);
        }