コード例 #1
0
        /// <summary>
        /// 依赖回调函数1
        /// </summary>
        private void LoadDepend1Complete(string label)
        {
            Debug.Log("依赖包1(贴图包)加载完毕,加载依赖包2(材质包)");
            SingleABLoader _DependLoader = new SingleABLoader(dependLabel2, LoadDepend2Complete);

            StartCoroutine(_DependLoader.LoadAssetBundle());
        }
コード例 #2
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        public IEnumerator LoadAssetBundle(string label)
        {
            //AB包关系的建立
            if (!relationDict.ContainsKey(label))
            {
                Relation relation = new Relation(label);
                relationDict.Add(label, relation);
            }
            Relation currentRelation = relationDict[label];

            //得到指定AB包所有的依赖关系(查询Manifest清单文件)
            string[] dependences = ManifestLoader.Instance.RetrievalDependences(label);
            for (int i = 0; i < dependences.Length; i++)
            {
                //添加“依赖”项
                currentRelation.AddDependence(dependences[i]);
                //添加“引用”项(使用协程递归调用)
                yield return(LoadReference(dependences[i], label));
            }

            //真正加载AB包
            if (loaderCacheDict.ContainsKey(label))
            {
                yield return(loaderCacheDict[label].LoadAssetBundle());
            }
            else
            {
                loader = new SingleABLoader(label, LoadComplete);
                loaderCacheDict.Add(label, loader);
                yield return(loader.LoadAssetBundle());
            }
        }
コード例 #3
0
        private void LoadDependAB2Complete(string abName)
        {
            Debug.Log(abName + "加载完成");

            loader = new SingleABLoader(abName1, LoadAB1Complete);
            StartCoroutine(loader.LoadAssetBundle());
        }
コード例 #4
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        public IEnumerator LoadAssetBundle(string abName)
        {
            // AB包关系的建立
            if (!abRelationDict.ContainsKey(abName))
            {
                ABRelation abRelation = new ABRelation(abName);
                abRelationDict.Add(abName, abRelation);
            }

            ABRelation tempABRelation = abRelationDict[abName];

            // 得到指定AB包所有的依赖关系(查询manifest文件)
            string[] abDependencyArr = ABManifestLoader.Instance.GetAllDependency(abName);

            foreach (var item in abDependencyArr)
            {
                Debug.Log("abName: " + abName + ", depenABName: " + item);

                // 添加依赖项
                tempABRelation.AddDependency(item);
                // 添加被引用项
                yield return(LoadReference(item, abName));
            }

            //Debug.Log(tempABRelation.GetAllDependency());
            //Debug.Log(tempABRelation.GetAllReference());


            // 真正加载AB包
            if (singleABLoaderDict.ContainsKey(abName))
            {
                yield return(singleABLoaderDict[abName].LoadAssetBundle());
            }
            else
            {
                singleABLoader = new SingleABLoader(abName, LoadABCompleted);
                singleABLoaderDict.Add(abName, singleABLoader);

                yield return(singleABLoader.LoadAssetBundle());
            }
        }
コード例 #5
0
 /// <summary>
 /// 依赖回调函数2
 /// </summary>
 private void LoadDepend2Complete(string label)
 {
     Debug.Log("依赖包2(材质包)加载完毕,开始正式加载预设包");
     _SingleABLoader = new SingleABLoader(this.label, LoadComplete);
     StartCoroutine(_SingleABLoader.LoadAssetBundle());
 }
コード例 #6
0
        private void Start()
        {
            SingleABLoader _DependLoader = new SingleABLoader(dependLabel1, LoadDepend1Complete);

            StartCoroutine(_DependLoader.LoadAssetBundle());
        }