private IEnumerator LoadLocalGameResAsync() { string xmlPath = string.Format("{0}{1}", ABConfiger.PACKAGE_STREAMING_DATA_PATH, TableGameRes.FILE_NAME); Debug.Log("streaming xml file path==" + xmlPath); WWW xmlWWW = new WWW(xmlPath); yield return(xmlWWW); byte[] datas = xmlWWW.bytes; if (datas == null || datas.Length <= 0) { Debug.LogError("Load resConfig xml in streaming path error!"); yield break; } // copy file to sandbox string sandBoxPath = ABConfiger.GetSandboxFilePath(TableGameRes.FILE_NAME); File.WriteAllBytes(sandBoxPath, datas); xmlWWW.Dispose(); xmlWWW = null; // read file in sandbox localTableResConfig = XMLSerializer.Read <TableGameRes>(datas) as TableGameRes; LoadResConfigComplete(); }
public void LoadABManifest(bool isPermanent = false) { ResourceInfo bundle = GetResourceInfo(ABConfiger.ASSET_MANIFEST_NAME, ResourceType.RES_ASSETBUNDLE, isPermanent); string path = ABConfiger.GetABFilePath(ABConfiger.ASSET_MANIFEST_NAME); Debug.Log("load asset bundle url==" + path); if (path == string.Empty) { RemoveResourceInfo(ABConfiger.ASSET_MANIFEST_NAME); return; } AssetBundle assetBundle = AssetBundle.LoadFromFile(path); if (assetBundle == null) { RemoveResourceInfo(ABConfiger.ASSET_MANIFEST_NAME); Debug.LogError("Load Local Manifest error!"); return; } assetBundleManifest = assetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); bundle._assetObj = assetBundle; }
/// <summary> /// 同步大厅资源配置数据 /// </summary> /// <param name="lobbyResConfig"></param> public void SyncLobbyResConfig(LobbyResConfig lobbyResConfig) { LocalTableResConfig.lobbyResConfig = lobbyResConfig; ABAssetDataMgr.Instance.SyncLobbyAssetInfo(LocalTableResConfig); string xmlPath = ABConfiger.GetSandboxFilePath(TableGameRes.FILE_NAME); XMLSerializer.Save <TableGameRes>(xmlPath, LocalTableResConfig); }
private AssetBundle LoadAssetBundle(string name, string abPath) { string path = ABConfiger.GetABFilePath(abPath); AssetBundle assetbundle = AssetBundle.LoadFromFile(path); if (assetbundle == null) { return(null); } loadedAssetBundles.Add(name, new LoadedAssetBundle(name, assetbundle)); return(assetbundle); }
/// <summary> /// 读取本地资源配置数据 /// </summary> public void LoadLocalGameRes() { // 首先读取沙盒目录下资源配置文件 string xmlPath = ABConfiger.GetSandboxFilePath(TableGameRes.FILE_NAME); Debug.Log("Sandbox xml file path====" + xmlPath); if (MLFileUtil.CheckFileExits(xmlPath)) { localTableResConfig = XMLSerializer.Read <TableGameRes>(xmlPath) as TableGameRes; LoadResConfigComplete(); return; } CoroutineManger.Instance.StartCoroutine(LoadLocalGameResAsync()); }
/// <summary> /// 同步具体产品游戏资源配置数据 /// </summary> public void SyncGameResConfig(GameResConfig gameResConfig, int productId) { BaseRes newGameRes = gameResConfig.FindProductRes(productId); if (newGameRes == null) { return; } LocalTableResConfig.gameResConfig.RebuildGameRes(newGameRes, productId); ABAssetDataMgr.Instance.SyncGameAssetInfo(LocalTableResConfig, productId); string xmlPath = ABConfiger.GetSandboxFilePath(TableGameRes.FILE_NAME); XMLSerializer.Save <TableGameRes>(xmlPath, LocalTableResConfig); }
private IEnumerator StartDownload(WWWRequest request) { //Debug.Log("url=====" + request.url); request.www = new WWW(request.url); yield return(request.www); while (!request.www.isDone) { yield return(null); } string filePath = ABConfiger.GetSandboxFilePath(path); Debugger.Log("filePath===" + filePath); byte[] datas = request.www.bytes; MLFileUtil.SaveFile(filePath, bundleFullPath, datas); }
private IEnumerator LoadAsyncAssetBundle(string name, string abPath, Action <UnityEngine.Object> load = null) { string path = ABConfiger.GetABFilePath(abPath); var bundleLoadRequest = AssetBundle.LoadFromFileAsync(path); while (!bundleLoadRequest.isDone) { yield return(null); } var assetBundle = bundleLoadRequest.assetBundle; if (assetBundle == null) { loadedAssetBundles.Add(name, new LoadedAssetBundle(name, true, null)); yield break; } loadedAssetBundles.Add(name, new LoadedAssetBundle(name, assetBundle)); if (load != null) { load(assetBundle); } }