Exemplo n.º 1
0
 /// <summary>
 /// 加载AB包中资源
 /// </summary>
 /// <param name="scenesName"></param>
 /// <param name="abName">ab名称</param>
 /// <param name="assetName">资源名称</param>
 /// <param name="isCache">是否使用缓存</param>
 /// <returns></returns>
 public UnityEngine.Object LoadAsset(string scenesName, string abName, string assetName, bool isCache)
 {
     if (_DicAllScenes.ContainsKey(scenesName))
     {
         MultiABMgr multObj = _DicAllScenes[scenesName];
         return(multObj.LoadAsset(abName, assetName, isCache));
     }
     Debug.LogError("LoadAsset方法加载错误,找不到场景名称,资源加载失败. SceneName = " + scenesName);
     return(null);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 释放资源
 /// </summary>
 /// <param name="scenesName"></param>
 public void DisposeAllAssets(string scenesName)
 {
     if (_DicAllScenes.ContainsKey(scenesName))
     {
         MultiABMgr multObj = _DicAllScenes[scenesName];
         multObj.DisPoseAllAsset();
     }
     else
     {
         Debug.LogError("DisposeAllAssets方法加载错误,找不到场景名称. SceneName = " + scenesName);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 下载AB指定包
        /// </summary>
        /// <param name="scenesName"></param>
        /// <param name="abName"></param>
        /// <param name="loadAllCompleteHandle">调用是否完成</param>
        /// <returns></returns>
        public IEnumerator LoadAssetBundlePack(string scenesName, string abName, DeLoadComplete loadAllCompleteHandle)
        {
            //参数检查
            if (string.IsNullOrEmpty(scenesName) || string.IsNullOrEmpty(abName))
            {
                Debug.LogError("LoadAssetBundlePack方法加载错误,场景名或AB包名称错误");
                yield return(null);
            }
            //等待manifest 清单文件加载完成
            while (!ABMainfestLoader.GetInstance().IsLoadCompleted)
            {
                yield return(null);
            }
            _ManifestObj = ABMainfestLoader.GetInstance().GetABManifest();
            if (_ManifestObj == null)
            {
                Debug.LogError("LoadAssetBundlePack方法加载错误,_ManifestObj为空");
                yield return(null);
            }
            //当前场景加入集合
            if (!_DicAllScenes.ContainsKey(scenesName))
            {
                MultiABMgr multiObj = new MultiABMgr(scenesName, abName, loadAllCompleteHandle);
                _DicAllScenes.Add(scenesName, multiObj);
            }

            //调用下一层  多包管理类
            MultiABMgr tmpMultiObj = _DicAllScenes[scenesName];

            if (tmpMultiObj == null)
            {
                Debug.LogError("LoadAssetBundlePack方法加载错误,tmpMultiObj为空");
            }
            //调用多包管理类  加载指定AB包
            yield return(tmpMultiObj.LoadAssetBundle(abName));
        }