private void BeginPackPackageResource(PackageResourceCompressType compressType, string sourceDirectory, string targetDirectory) { m_ReportConfig = new PackageResourceConfig(); m_ReportConfig.compressType = (int)compressType; m_ReportConfig.fileList = new List <string>(); // get compressor var compressor = PackageResourceCompressHelper.GetCompress(compressType); if (null == compressor) { Debug.LogError("Unsupport compress type " + compressType); return; } // sign list StringBuilder allFileCRC32Code = new StringBuilder(); // create file list var fileList = GetFileList(sourceDirectory, targetDirectory); for (int i = 0; i < fileList.Count; ++i) { var elem = fileList[i]; // load file to memory byte[] content = File.ReadAllBytes(elem.GetSourcePath()); // compess file with compress type content = CompressFile(content, compressor); // get crc32 allFileCRC32Code.Append(CRC32.GetCRC32byte(content)); // get output path string outputPath = elem.GetOutputPath(); // ensure folder PackageResourceTool.EnsureFolder(outputPath); // write file to target directory File.WriteAllBytes(outputPath, content); // update report m_ReportConfig.fileList.Add(elem.GetSubpath()); } // update report version m_ReportConfig.version = CRC32.GetCRC32Str(allFileCRC32Code.ToString()).ToString(); // save report file var reportFile = XmlConfigBase.Serialize(m_ReportConfig); File.WriteAllText(targetDirectory + m_strPackageResourceConfigName, reportFile); }
private void CombineData() { if (m_TmpConfigList.Count <= 0) { Tip("没找到 " + PrefixName + " 文件"); return; } RunnerTrunkTableConfig table = new RunnerTrunkTableConfig(); table.TrunkList = new List <RunnerTrunkConfig>(); for (int i = 0; i < m_TmpConfigList.Count; ++i) { RunnerTrunkConfig elem = RunnerTrunkElementConfig.ConvertToConfig(m_TmpConfigList[i]); table.TrunkList.Add(elem); } string xmlData = XmlConfigBase.Serialize(table); FileUtils.WriteStringFile(xmlData, m_strDataOutputPath + "/" + m_strXmlName); }
private void Test() { if (Application.platform == RuntimePlatform.Android && (Input.GetKeyDown(KeyCode.Escape))) { TipManager.Instance.Alert("", "你确定要退出游戏吗?", "确定", "取消", (res) => { if (res) { Application.Quit(); } }); } if (Input.GetKeyDown(KeyCode.F1)) { WindowBase window = WindowManager.Instance.GetWindow(WindowID.MissionDebugAttach); if (null == window) { WindowManager.Instance.OpenWindow(WindowID.MissionDebugAttach); } else { if (window.IsOpen()) { window.Close(); } else { WindowManager.Instance.OpenWindow(WindowID.MissionDebugAttach); } } } if (Input.GetKeyDown(KeyCode.C) || Input.touchCount == 3) { string filepath = ResourceManager.Instance.GetStreamAssetPath() + "/config.xml"; ResourceManager.Instance.LoadStreamingAssetsData(filepath, (www) => { SysConfig tmp = XmlConfigBase.DeSerialize <SysConfig>(www.text); Debuger.LogError("system config decode result : " + tmp == null); if (tmp != null) { Debuger.LogError(tmp.ServerConfigPath); Debuger.LogError(tmp.ClientConfigPath); Debuger.LogError(tmp.ExcelPath); Debuger.LogError(tmp.ConfigCenterUrl); Debuger.LogError(tmp.UploadUrl); Debuger.LogError("begin encode resoult"); string res = XmlConfigBase.Serialize(tmp); Debuger.LogError("encode result:" + res); FileUtils.WriteStringFile(Application.persistentDataPath + "/tesw.xml", res); tmp = XmlConfigBase.DeSerialize <SysConfig>(res); Debuger.LogError("xxx system config decode result : " + tmp == null); if (tmp != null) { Debuger.LogError(tmp.ServerConfigPath); Debuger.LogError(tmp.ClientConfigPath); Debuger.LogError(tmp.ExcelPath); Debuger.LogError(tmp.ConfigCenterUrl); Debuger.LogError(tmp.UploadUrl); Debuger.LogError("begin encode resoult"); res = XmlConfigBase.Serialize(tmp); Debuger.LogError("encode result:" + res); FileUtils.WriteStringFile(Application.persistentDataPath + "/tesw1.xml", res); } } }); } }
private void SaveSystemConfig() { var content = XmlConfigBase.Serialize(SystemConst.Config); File.WriteAllText(SystemConst.settingConfigPath, content); }