public static RecordTable Analysis(string data) { var result = new RecordTable(); var tmp = JsonTool.Json2Dictionary <SingleField>(data); var keys = new List <string>(tmp.Keys); for (int i = 0; i < keys.Count; i++) { result.Add(keys[i], tmp[keys[i]]); } return(result); }
void AddFieldGUI(Dictionary <string, SingleField> dict) { EditorGUI.indentLevel = 1; isFold = EditorGUILayout.Foldout(isFold, "新增字段"); if (isFold) { EditorGUI.indentLevel = 2; fieldName = EditorGUILayout.TextField("字段名", fieldName); newType = (FieldType)EditorGUILayout.EnumPopup("字段类型", content.m_type); if (content.m_type != newType) { content.m_type = newType; content.Reset(); } content.m_content = EditorUtilGUI.FieldGUI_Type(content); if (!dict.ContainsKey(fieldName) && fieldName != "") { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("新增", GUILayout.Width(position.width - 60))) { m_currentRecord.Add(fieldName, content); fieldName = ""; content = new SingleField(); newType = content.m_type; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } else { if (dict.ContainsKey(fieldName)) { EditorGUILayout.LabelField("已存在该字段"); } } } }
public static RecordTable Analysis(string data) { RecordTable result = new RecordTable(); Dictionary <string, SingleField> tmp = JsonTool.Json2Dictionary <SingleField>(data); List <string> keys = new List <string>(tmp.Keys); for (int i = 0; i < keys.Count; i++) { //Debug.Log("Key: " + keys[i]); result.Add(keys[i], tmp[keys[i]]); } return(result); }
void AddFieldGUI(Dictionary <string, SingleField> dict) { EditorGUI.indentLevel = 1; isFold = EditorGUILayout.Foldout(isFold, "新增字段"); if (isFold) { EditorGUI.indentLevel = 2; bool isNewType = false; fieldName = EditorGUILayout.TextField("字段名", fieldName); newType = (FieldType)EditorGUILayout.EnumPopup("字段类型", content.m_type); if (newType == FieldType.Enum) { int newIndex = EditorGUILayout.Popup("枚举类型", m_newTypeIndex, EditorTool.GetAllEnumType()); if (newIndex != m_newTypeIndex) { m_newTypeIndex = newIndex; isNewType = true; } } if (content.m_type != newType) { isNewType = true; } if (isNewType) { content.m_type = newType; content.m_enumType = EditorTool.GetAllEnumType()[m_newTypeIndex]; content.Reset(); } content.m_content = EditorUtilGUI.FieldGUI_Type(content); if (!dict.ContainsKey(fieldName) && fieldName != "") { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("新增", GUILayout.Width(position.width - 60))) { m_currentRecord.Add(fieldName, content); fieldName = ""; content = new SingleField(); newType = content.m_type; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } else { if (dict.ContainsKey(fieldName)) { EditorGUILayout.LabelField("已存在该字段"); } } } }