bool ParseDataSet(string filename, DataSet data) { if (data == null) { EditorUtility.DisplayDialog("警告", string.Format("{1}读取时出现错误!", filename), "好的"); return(false); } var table = data.Tables[0]; if (table == null) { EditorUtility.DisplayDialog("警告", string.Format("{1}的第一个Table页不存在!", filename), "好的"); return(false); } var rows = table.Rows; if (rows == null) { EditorUtility.DisplayDialog("警告", string.Format("{1}的数据为空!", filename), "好的"); return(false); } if (rows.Count < 3) { EditorUtility.DisplayDialog("警告", string.Format("{1}的行数不正确,请保证至少有三行!", filename), "好的"); return(false); } Cfg cfg = new Cfg(); cfg.Name = filename + "Cfg"; //字段名 foreach (var n in rows[0].ItemArray) { cfg.fileNames.Add(n.ToString()); } //类型 foreach (var n in rows[1].ItemArray) { string t = n.ToString().ToLower(); cfg.types.Add(t); } //注释 foreach (var n in rows[2].ItemArray) { cfg.notates.Add(n.ToString()); } //数据 for (int i = 3; i < rows.Count; i++) { cfg.items.Add(rows[i]); } if (cfg.CheckID()) { cfgs.Add(cfg); } else { EditorUtility.DisplayDialog("警告", string.Format("{0}的ID字段不存在或者有重复ID,请检查!", cfg.Name), "好的"); return(false); } return(true); }