void EditorDataGUI() { m_isEditorFold = EditorGUILayout.Foldout(m_isEditorFold, "编辑数据"); EditorGUI.indentLevel++; if (m_isEditorFold) { List <string> keys = m_currentData.TableKeys; m_EditorPos = EditorGUILayout.BeginScrollView(m_EditorPos, GUILayout.ExpandHeight(false)); for (int i = 0; i < keys.Count; i++) { string key = keys[i]; FieldType type = m_currentData.GetFieldType(key); int EnumTypeIndex = EditorTool.GetAllEnumTypeIndex(m_currentData.GetEnumType(key)); if (i == 0) { EditorGUILayout.LabelField("<主键>字段名", key); EditorGUILayout.LabelField("字段类型", m_currentData.GetFieldType(keys[i]).ToString()); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("字段名", key); if (GUILayout.Button("删除字段")) { if (EditorUtility.DisplayDialog("警告", "确定要删除该字段吗?", "是", "取消")) { DeleteField(m_currentData, key); continue; } } EditorGUILayout.EndHorizontal(); bool isNewType = false; m_editorNoteContent = EditorGUILayout.TextField("注释", m_currentData.GetNote(key)); m_currentData.SetNote(key, m_editorNoteContent); m_editorNewType = (FieldType)EditorGUILayout.EnumPopup("字段类型", type); if (m_editorNewType == FieldType.Enum) { m_editorNewEnumIndex = EditorGUILayout.Popup("枚举类型", EnumTypeIndex, EditorTool.GetAllEnumType()); if (EnumTypeIndex != m_editorNewEnumIndex) { isNewType = true; } } if (type != m_editorNewType) { isNewType = true; } if (isNewType) { //弹出警告并重置数据 if (EditorUtility.DisplayDialog("警告", "改变字段类型会重置该字段的所有数据和默认值\n是否继续?", "是", "取消")) { m_currentData.SetFieldType(key, m_editorNewType, EditorTool.GetAllEnumType()[m_editorNewEnumIndex]); ResetDataField(m_currentData, key, m_editorNewType, EditorTool.GetAllEnumType()[m_editorNewEnumIndex]); type = m_editorNewType; EnumTypeIndex = m_editorNewEnumIndex; content = new SingleData(); } } string newContent; if (type == FieldType.Enum) { newContent = EditorUtilGUI.FieldGUI_Type(type, EditorTool.GetAllEnumType()[EnumTypeIndex], m_currentData.GetDefault(key), "默认值"); } else { newContent = EditorUtilGUI.FieldGUI_Type(type, null, m_currentData.GetDefault(key), "默认值"); } m_currentData.SetDefault(key, newContent); } EditorGUILayout.Space(); } EditorGUILayout.EndScrollView(); AddFieldGUI(); } }