private void bAddGroup_Click(object sender, EventArgs e) { var smsSettings = new XmlGroupSettings(); smsSettings.GroupName = ResourceManagerProvider.GetLocalizedString("LST_GROUP_NAME_NEW", Application.CurrentCulture); smsSettings.SmsRecipient = "0000"; smsSettings.SmsText = "%PHONE%"; smsSettings.UssdText = "%PHONE%"; GroupSettings.Add(smsSettings); DataBind(); }
/// <summary> /// 序列化所有xml配置文件; /// </summary> private static void SerializeAllXml(List <XmlGroupSettings> groups) { try { List <string> gs = new List <string>(); for (int i = 0, imax = groups.Count; i < imax; i++) { XmlGroupSettings group = groups[i]; FunPlus.Common.Config.XmlSerializer.SerializeXmls(group); gs.Add(group.group); } AssetDatabase.Refresh(); Debug.Log("xml serialize"); } catch (Exception e) { Debug.LogException(e); EditorUtility.DisplayDialog("Xml Serialize Failed !", "See console for more details.\n\n" + e.Message, "OK"); } }
private static void GetAllFileByXmlLevelGroup(GameConfigGroups groups) { if (!CheckGroup(groups)) { return; } GameXmlGroup[] gameXmlGroups = groups.gameXmlGroups; //获取序列化xmlgroups所需要的数据; if (gameXmlGroups != null && gameXmlGroups.Length > 0) { XmlGroupSettings tempXmlGroups = null; //detail config mXmlLevelGroups.Clear(); for (int i = 0; i < gameXmlGroups.Length; i++) { tempXmlGroups = new XmlGroupSettings(); List <GameXmlFile> t_files = new List <GameXmlFile> (gameXmlGroups[i].gameXmlFiles); for (int j = 0; j < t_files.Count; j++) { string t_name = Path.GetFileNameWithoutExtension(t_files[j].Path); if (string.IsNullOrEmpty(t_name)) { GameXmlFile temp = t_files [j]; t_files.Remove(temp); string dirPath = string.Format("{0}/../conf/{1}", Application.dataPath, temp.Path); if (!Directory.Exists(dirPath)) { Debug.LogError("dir is not exists : " + dirPath); continue; } string[] allPath = Directory.GetFiles(dirPath, "*.xml", SearchOption.AllDirectories); for (int t = 0; t < allPath.Length; t++) { GameXmlFile xFile = new GameXmlFile(); xFile.Path = allPath[t].Replace('\\', '/'); string t_Path = string.Format("{0}/../conf/", Application.dataPath); xFile.Path = xFile.Path.Replace(t_Path, ""); xFile.TypeName = temp.TypeName; t_files.Insert(j, xFile); } } } GameXmlFile[] files = t_files.ToArray(); tempXmlGroups.group = string.Format("{0}/../conf/{1}", Application.dataPath, gameXmlGroups[i].Group); if (files == null) { Debug.LogError("xmlgroup config error!"); return; } tempXmlGroups.xmlFiles = new XmlGroupSettings.XmlData[files.Length]; for (int j = 0; j < files.Length; j++) { tempXmlGroups.xmlFiles[j] = new XmlGroupSettings.XmlData(); tempXmlGroups.xmlFiles[j].path = string.Format("{0}/../conf/{1}", Application.dataPath, files[j].Path.Replace('\\', '/')); tempXmlGroups.xmlFiles[j].typeName = files[j].TypeName; } mXmlLevelGroups.Add(tempXmlGroups); tempXmlGroups = null; } } }
// 替换为相对路径; private static void ReplaceRelativePath(ref ConfigGroupsSettings conf) { if (conf == null) { return; } string rootPath = Application.dataPath + "/../"; if (conf.xmlGroups != null) { for (int i = 0; i < conf.xmlGroups.Length; i++) { XmlGroupSettings xmlGroupSettings = conf.xmlGroups[i]; if (xmlGroupSettings == null) { continue; } xmlGroupSettings.group = xmlGroupSettings.group.Replace(rootPath, ""); if (xmlGroupSettings.xmlFiles == null) { continue; } for (int j = 0, jmax = xmlGroupSettings.xmlFiles.Length; j < jmax; j++) { XmlGroupSettings.XmlData xmlData = xmlGroupSettings.xmlFiles[j]; if (xmlData == null) { continue; } xmlData.path = xmlData.path.Replace(rootPath, ""); } } } if (conf.xmlSheetGroups != null) { for (int i = 0; i < conf.xmlSheetGroups.Length; i++) { XmlSheetGroupSettings xmlSheetGroupSettings = conf.xmlSheetGroups[i]; if (xmlSheetGroupSettings == null) { continue; } xmlSheetGroupSettings.group = xmlSheetGroupSettings.group.Replace(rootPath, ""); if (xmlSheetGroupSettings.sheetFiles == null) { continue; } for (int j = 0, jmax = xmlSheetGroupSettings.sheetFiles.Length; j < jmax; j++) { XmlSheetGroupSettings.XmlSheetData xmlSheetData = xmlSheetGroupSettings.sheetFiles[j]; if (xmlSheetData == null || xmlSheetData.files == null) { continue; } for (int k = 0, kmax = xmlSheetData.files.Length; k < kmax; k++) { XmlSheetGroupSettings.XmlSheetFile xmlSheetFile = xmlSheetData.files[k]; if (xmlSheetFile == null) { continue; } xmlSheetFile.filePath = xmlSheetFile.filePath.Replace(rootPath, ""); } } } } }