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

            //得到指定AB包所有的依赖关系
            string[] strDepencedArray = ABManifestLoader.GetInstance().RetrivalDependences(abName);
            foreach (string item_Depence in strDepencedArray)
            {
                //添加“依赖”项
                tmpABRelationObj.AddDependence(item_Depence);
                //添加“引用”项
                yield return(LoadReference(item_Depence, abName));
            }

            //真正的AB包加载
            if (_DicSingleABLoaderCache.ContainsKey(abName))
            {
                yield return(_DicSingleABLoaderCache[abName].LoadAssetBundle());
            }
            else
            {
                _CurrentSingleABLoader = new SingleABLoader(abName, CompletLoadAB);
                _DicSingleABLoaderCache.Add(abName, _CurrentSingleABLoader);
                yield return(_CurrentSingleABLoader.LoadAssetBundle());
            }
        }//Method_end
示例#2
0
 private void Start()
 {
     loaderObj = new SingleABLoader(_ABName1, LoadCompleate);
     //加载AB资源包
     StartCoroutine(loaderObj.LoadAssetBundle());
 }