public static void Initialize() { ResourcesConfigStruct result = GetResourcesConfig(); m_relyBundleConfigs = result.relyList; m_bundleConfigs = result.bundleList; }
public static ResourcesConfigStruct AnalysisResourcesConfig2Struct(string content) { if (content == null || content == "") { throw new Exception("ResourcesConfigcontent is null ! "); } ResourcesConfigStruct result = new ResourcesConfigStruct(); Dictionary <string, object> data = (Dictionary <string, object>)FrameWork.Json.Deserialize(content); Dictionary <string, object> gameRelyBundles = (Dictionary <string, object>)data[c_relyBundleKey]; Dictionary <string, object> gameAssetsBundles = (Dictionary <string, object>)data[c_bundlesKey]; result.relyList = new Dictionary <string, ResourcesConfig>(); result.bundleList = new Dictionary <string, ResourcesConfig>(); foreach (object item in gameRelyBundles.Values) { Dictionary <string, object> tmp = (Dictionary <string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = (tmp["relyPackages"].ToString()).Split('|'); config.md5 = (string)tmp["md5"]; result.relyList.Add(config.name, config); } foreach (object item in gameAssetsBundles.Values) { Dictionary <string, object> tmp = (Dictionary <string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = ((string)tmp["relyPackages"]).Split('|'); config.md5 = (string)tmp["md5"]; result.bundleList.Add(config.name, config); } return(result); }
public static ResourcesConfigStruct AnalysisResourcesConfig2Struct(string content) { if (content == null || content =="") { throw new Exception("ResourcesConfigcontent is null ! "); } ResourcesConfigStruct result = new ResourcesConfigStruct(); Dictionary<string, object> data = (Dictionary<string, object>)MiniJSON.Json.Deserialize(content); Dictionary<string, object> gameRelyBundles = (Dictionary<string, object>)data[c_relyBundleKey]; Dictionary<string, object> gameAssetsBundles = (Dictionary<string, object>)data[c_bundlesKey]; result.relyList = new Dictionary<string, ResourcesConfig>(); result.bundleList = new Dictionary<string, ResourcesConfig>(); foreach (object item in gameRelyBundles.Values) { Dictionary<string, object> tmp = (Dictionary<string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = ((string)tmp["relyPackages"]).Split('|'); config.md5 = (string)tmp["md5"]; result.relyList.Add(config.name,config); } foreach (object item in gameAssetsBundles.Values) { Dictionary<string, object> tmp = (Dictionary<string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = ((string)tmp["relyPackages"]).Split('|'); config.md5 = (string)tmp["md5"]; result.bundleList.Add(config.name,config); } return result; }
/// <summary> /// 更新文件 /// </summary> /// <returns></returns> static IEnumerator DownLoadFile() { UpdateDateCallBack(HotUpdateStatusEnum.DownLoadingMd5File, GetHotUpdateProgress(true, false, 0)); //取得服务器版本文件 WWW www = new WWW(s_Md5FileDownLoadPath); Debug.Log("服务器获取MD5文件 :" + s_Md5FileDownLoadPath); //yield return www; while (!www.isDone) { UpdateDateCallBack(HotUpdateStatusEnum.DownLoadingMd5File, GetHotUpdateProgress(true, false, www.progress)); yield return(new WaitForEndOfFrame()); } if (www.error != null && www.error != "") { //下载失败 Debug.LogError("MD5 DownLoad Error " + www.error); UpdateDateCallBack(HotUpdateStatusEnum.Md5FileDownLoadFail, GetHotUpdateProgress(true, false, 0)); yield break; } m_Md5FileCache = ((TextAsset)www.assetBundle.mainAsset).text; www.assetBundle.Unload(true); UpdateDateCallBack(HotUpdateStatusEnum.DownLoadingMd5File, GetHotUpdateProgress(true, false, 1)); ResourcesConfigStruct serviceFileConfig = ResourcesConfigManager.AnalysisResourcesConfig2Struct(m_Md5FileCache); ResourcesConfigStruct localFileConfig = ResourcesConfigManager.AnalysisResourcesConfig2Struct(ResourcesConfigManager.ReadResourceConfigContent()); s_downLoadList = new List <ResourcesConfig>(); CheckBundleList(serviceFileConfig.relyList, localFileConfig.relyList); CheckBundleList(serviceFileConfig.bundleList, localFileConfig.bundleList); yield return(StartDownLoad()); }