コード例 #1
0
 //依赖回调函数2
 private void LoadDependComplete2(string abName)
 {
     Debug.Log("依赖包2(材质包)加载完毕,开始正式加载预设包");
     _LoadObj = new SingleABLoader(_ABName1, LoadComplete);
     //加载AB依赖包
     StartCoroutine(_LoadObj.LoadAssetBundle());
 }
コード例 #2
0
ファイル: MultiABMgr.cs プロジェクト: Keyden/ABFramwork
        /// <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());
            }
        }
コード例 #3
0
        private string _AssetName1 = "TestCubePrefab.prefab";//Capsule.prefab


        #region 简单(无依赖包)预设的加载
        //private void Start()
        //{
        //    _LoadObj = new SingleABLoader(_ABName1, LoadComplete);
        //    //加载AB包
        //    StartCoroutine(_LoadObj.LoadAssetBundle());
        //}

        ///// <summary>
        ///// 回调函数(一定条件下自动执行)
        ///// </summary>
        ///// <param name="abName"></param>
        //private void LoadComplete(string abName)
        //{
        //    //加载AB包中的资源
        //    UnityEngine.Object tmpObj=_LoadObj.LoadAsset(_AssetName1,false);
        //    //克隆对象
        //    Instantiate(tmpObj);
        //}

        #endregion

        private void Start()
        {
            SingleABLoader _LoadDependObj = new SingleABLoader(_ABDependName1, LoadDependComplete1);

            //加载AB依赖包
            StartCoroutine(_LoadDependObj.LoadAssetBundle());
        }
コード例 #4
0
        //依赖回调函数1
        private void LoadDependComplete1(string abName)
        {
            Debug.Log("依赖包1(贴图包)加载完毕,加载依赖包2(材质包)");
            SingleABLoader _LoadDependObj2 = new SingleABLoader(_ABDependName2, LoadDependComplete2);

            //加载AB依赖包
            StartCoroutine(_LoadDependObj2.LoadAssetBundle());
        }
コード例 #5
0
 private void LoadComplete2(string _ABName2)
 {
     _LoadObj = new SingleABLoader(_ABName, LoadComplete);
     StartCoroutine(_LoadObj.LoadAssetBundle());
 }
コード例 #6
0
        private void LoadComplete1(string _ABName1)
        {
            SingleABLoader load2 = new SingleABLoader(_ABDependName2, LoadComplete2);

            StartCoroutine(load2.LoadAssetBundle());
        }
コード例 #7
0
        private string _ABDependName2 = "scene_1/materials.ab"; //材质

        private void Start()
        {
            SingleABLoader load1 = new SingleABLoader(_ABDependName1, LoadComplete1);

            StartCoroutine(load1.LoadAssetBundle());
        }