Exemplo n.º 1
0
        //加载AB包
        public IEnumerator LoadAssetBundeler(string mAbName)
        {
            //ab包关系建立
            ABrelation tempRelation = null;

            if (!dicABrelaion.ContainsKey(mAbName))
            {
                tempRelation = new ABrelation(mAbName);
                dicABrelaion.Add(mAbName, tempRelation);
            }
            tempRelation = dicABrelaion[mAbName];
            //得到指定AB包所欲依赖关系
            string[] strDependeceArray = ABManifestLoader.Instance.RertiveDependencies(mAbName);
            foreach (string item_Depence in strDependeceArray)
            {
                //添加依赖项
                tempRelation.AddDependence(item_Depence);
                //添加引用项
                yield return(this.LoadReference(item_Depence, mAbName));
            }
            //真正加载ab包
            if (this.abLoaderCache.ContainsKey(mAbName))
            {
                yield return(this.abLoaderCache[mAbName].LoadAssetBundle());
            }
            else
            {
                aBLoader = new ABLoader(mAbName, this.CompleteAB);
                this.abLoaderCache.Add(mAbName, this.aBLoader);
                yield return(this.abLoaderCache[mAbName].LoadAssetBundle());
            }
        }
Exemplo n.º 2
0
        //加载引用ab包
        private IEnumerator LoadReference(string mAbName, string refABName)
        {
            ABrelation tempRelation = null;

            if (dicABrelaion.ContainsKey(mAbName))
            {
                tempRelation = dicABrelaion[mAbName];
                //添加AB引用关系(被依赖)
                tempRelation.AddReference(refABName);
            }
            else
            {
                tempRelation = new ABrelation(mAbName);
                tempRelation.AddReference(refABName);
                dicABrelaion.Add(mAbName, tempRelation);
                //开始加载依赖包
                yield return(this.LoadAssetBundeler(mAbName));
            }
        }