Exemplo n.º 1
0
 /// <summary>
 /// 加载(AB包内)资源
 /// </summary>
 /// <param name="scenesName">场景名称</param>
 /// <param name="abName">AssetBundle 名称</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 multiObj = _DicAllScenes[scenesName];
         return(multiObj.LoadAsset(abName, assetName, isCache));
     }
     Debug.LogError(GetType() + "/LoadAsset()/找不到场景: " + scenesName + " ,无法加载AssetBundle 资源,请检查!");
     return(null);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 释放一个场景中所有的资源
 /// </summary>
 /// <param name="scenesName"></param>
 /// <returns></returns>
 public void DisposeAllAssets(string scenesName)
 {
     if (_DicAllScenes.ContainsKey(scenesName))
     {
         MultiABMgr multiObj = _DicAllScenes[scenesName];
         multiObj.DisposeAllAsset();
     }
     else
     {
         Debug.LogError(GetType() + "/DisposeAllAsset()/找不到场景: " + scenesName + " ,无法释放资源,请检查!");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 下载AssetBundle指定包
        /// </summary>
        /// <param name="sceneName">场景名称</param>
        /// <param name="abName">AssetBundle名称</param>
        /// <param name="loadAllABCompleteHandle">AssetBundle名称</param>
        public IEnumerator LoadAssetBundlePackage(string sceneName, string abName, DelLoadComplete loadAllABCompleteHandle)
        {
            //参数检查
            if (string.IsNullOrEmpty(sceneName) || string.IsNullOrEmpty(abName))
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePackage()/scenenName Or abName is Null ,请检查!");
                yield return(null);
            }
            //等待Manifest清单加载完成
            while (!ABManifestLoader.GetInstance().IsLoadFinish)
            {
                yield return(null);
            }
            //获取“AssetBundle(清单文件)系统类”
            _ManifestObj = ABManifestLoader.GetInstance().GetABManifest();
            //参数检查
            if (_ManifestObj == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePackage()/_ManifestObj==null,请先确保加载Manifest清单文件!");
                yield return(null);
            }
            //如果不包含指定场景,则先创建
            if (!_DicAllScenes.ContainsKey(sceneName))
            {
                CreateScenesAB(sceneName, abName, loadAllABCompleteHandle);
            }

            //调用下一层(“多AssetBundle管理”类)
            MultiABMgr tmpMultiABMgrObj = _DicAllScenes[sceneName];

            if (tmpMultiABMgrObj == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundlePackage()/tmpMultiABMgrObj==null , 请检查!");
            }
            yield return(tmpMultiABMgrObj.LoadAssetBundles(abName));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 创建一个“场景AssetBundle”且加入集合中
        /// </summary>
        /// <param name="scensName"></param>
        private void CreateScenesAB(string scensName, string abName, DelLoadComplete loadAllABCompleteHandle)
        {
            MultiABMgr multiABMgeObj = new MultiABMgr(scensName, abName, loadAllABCompleteHandle);

            _DicAllScenes.Add(scensName, multiABMgeObj);
        }