// 替换为相对路径; 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, ""); } } } } }
private static void GetAllFileBySheetGroup(GameConfigGroups groups) { if (!CheckGroup(groups)) { return; } GameXmlSheetGroup[] gameXmlSheetGroups = groups.gameXmlSheetGroups; //获取序列化xmlsheetgroups所需要的数据; if (gameXmlSheetGroups != null && gameXmlSheetGroups.Length > 0) { XmlSheetGroupSettings tempGroups = null; //detail config List <XmlSheetGroupSettings.XmlSheetFile> mXmlSheetFileList = new List <XmlSheetGroupSettings.XmlSheetFile>(); mXmlSheetGroups.Clear(); for (int i = 0; i < gameXmlSheetGroups.Length; i++) { tempGroups = new XmlSheetGroupSettings(); GameXmlSheet[] sheet = gameXmlSheetGroups[i].gameSheets; tempGroups.group = string.Format("{0}/../conf/{1}", Application.dataPath, gameXmlSheetGroups[i].Group); if (sheet == null) { Debug.LogError("xmlsheetgroups config error!"); return; } tempGroups.sheetFiles = new XmlSheetGroupSettings.XmlSheetData[sheet.Length]; for (int k = 0; k < sheet.Length; k++) { tempGroups.sheetFiles[k] = new XmlSheetGroupSettings.XmlSheetData(); tempGroups.sheetFiles[k].sheetName = sheet[k].SheetName; mXmlSheetFileList.Clear(); if (sheet[k].gameXmlSheetFile == null) { continue; } for (int j = 0; j < sheet[k].gameXmlSheetFile.Length; j++) { string dirPath = string.Format("{0}/../conf/{1}", Application.dataPath, sheet[k].gameXmlSheetFile[j].Dir); 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++) { XmlSheetGroupSettings.XmlSheetFile xFile = new XmlSheetGroupSettings.XmlSheetFile(); xFile.filePath = allPath[t].Replace('\\', '/'); xFile.typeName = sheet[k].gameXmlSheetFile[j].TypeName; mXmlSheetFileList.Add(xFile); } } tempGroups.sheetFiles[k].files = mXmlSheetFileList.ToArray(); mXmlSheetFileList.Clear(); } mXmlSheetGroups.Add(tempGroups); tempGroups = null; } } }