private static void GenData(IDataReadable rder) { IDataReadable reader = rder; XDocument xDoc = new XDocument(); XElement root = new XElement("Root"); xDoc.Add(root); //List<string> commentLine = reader.GetLine(0, 1); List <string> keyLine = reader.GetColume(1, 1); int num = 2; Array languageType = Enum.GetValues(typeof(LanguageConst.LanguageType)); for (int n = 0; n < languageType.Length; n++) { XElement languageEle = new XElement("item"); root.Add(languageEle); List <string> valueLine = reader.GetColume(num, 1, keyLine.Count); for (int i = 0; i < keyLine.Count; i++) { if (valueLine.Count > i) { languageEle.Add(new XElement(keyLine[i], valueLine[i])); } else { languageEle.Add(new XElement(keyLine[i], valueLine[i])); } } num++; } string outputPath = PathConfig.LanguageDataPath; if (!Directory.Exists(Path.GetDirectoryName(outputPath))) { Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); } xDoc.Save(outputPath); AssetDatabase.Refresh(); }
public void GenData(IDataReadable reader, string outputPath = null) { IDataReadable exReader = reader; XDocument xDoc = new XDocument(); XElement root = new XElement("Root"); xDoc.Add(root); List <string> name = exReader.GetMemberNames(); List <string> value = exReader.GetColume(2); for (int i = 0; i < name.Count; i++) { XElement item = new XElement(name[i], value[i]); root.Add(item); } if (outputPath == null) { outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Pref) + Path.GetFileNameWithoutExtension(reader.currentDataTypeName) + PrefData.m_fileExtention; } if (!Directory.Exists(Path.GetDirectoryName(outputPath))) { Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); } xDoc.Save(outputPath); AssetDatabase.Refresh(); var ai = AssetImporter.GetAtPath(PathEx.ConvertAbstractToAssetPath(outputPath)); ai.assetBundleName = PathConfig.DataBundleName; AssetDatabase.Refresh(); }