Beispiel #1
0
 public void Initialize(Action initOK)
 {
     StartCoroutine(ABManifestLoader.GetInstance().LoadManifestFile(delegate(AssetBundleManifest ManifestObj) {
         m_Manifest = ManifestObj;
         initOK();
     }));
 }
Beispiel #2
0
 /// <summary>
 /// 获取本类实例
 /// </summary>
 /// <returns></returns>
 public static ABManifestLoader GetInstance()
 {
     if (_Instance == null)
     {
         _Instance = new ABManifestLoader();
     }
     return(_Instance);
 }
Beispiel #3
0
        /// <summary>
        /// 下载AssetBundle 指定包
        /// </summary>
        /// <param name="scenesName">场景名称</param>
        /// <param name="abName">AssetBundle 包名称</param>
        /// <param name="loadCompleteHandle">委托: 调用是否完成</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundlePack(string scenesName, string abName, Action loadCompleteHandle)
        {
            //参数检查
            if (string.IsNullOrEmpty(scenesName) || string.IsNullOrEmpty(abName))
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePack()/ScenesName Or abName is null !, 请检查");
                yield return(null);
            }

            //等待Manifest清单文件加载完成
            while (!ABManifestLoader.GetInstance().IsLoadFinish)
            {
                yield return(null);
            }
            _ManifestObj = ABManifestLoader.GetInstance().GetABManifest();

            if (_ManifestObj == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePack()/_ManifestObj is null !, 请检查");
                yield return(null);
            }

            //把当前场景加入集合中
            if (!_DicAllScenes.ContainsKey(scenesName))
            {
                MultiABMgr multiMgrObj = new MultiABMgr(scenesName, abName);
                _DicAllScenes.Add(scenesName, multiMgrObj);
            }

            //调用下一层("多包管理类")
            MultiABMgr tmpMultiMgrObj = _DicAllScenes[scenesName];

            if (tmpMultiMgrObj == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePack()/tmpMultiMgrObj is null !, 请检查");
            }

            //调用 "多包管理类" 的加载指定AB包。
            yield return(tmpMultiMgrObj.LoadAssetBundler(abName, loadCompleteHandle));
        }//Method_end
Beispiel #4
0
        /// <summary>
        /// 加载AB包
        /// </summary>
        /// <param name="abName">AssetBundle 名称</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundler(string abName, Action loadCompleteHandle = null)
        {
            //AB包关系的建立
            if (!_DicABRelation.ContainsKey(abName))
            {
                ABRelation abRelationObj = new ABRelation(abName);

                _DicABRelation.Add(abName, abRelationObj);
            }

            ABRelation tmpABRelationObj = _DicABRelation[abName];

            string[] strDepedenceArray = ABManifestLoader.GetInstance().RetrivalDependce(abName);

            //得到指定AB包所有的依赖关系(查询Manifest清单文件)
            foreach (string item_Depence in strDepedenceArray)
            {
                //添加“依赖”项
                tmpABRelationObj.AddDependence(item_Depence);

                //添加"引用"项 (递归调用)
                yield return(LoadReference(item_Depence, abName));
            }

            //真正加载AB包
            if (m_LoadedAssetBundles.ContainsKey(abName))
            {
                Debug.LogError("这个包已经被加载过了: " + abName);
                //yield return m_LoadedAssetBundles[abName].LoadAssetBundle(loadCompleteHandle);
            }
            else
            {
                _CurrentSingleABLoader = new SingleABLoader(abName);
                //m_LoadedAssetBundles.Add(abName, _CurrentSingleABLoader);
                yield return(_CurrentSingleABLoader.LoadAssetBundle(loadCompleteHandle));
            }
        }//Method_end