void AddDataGUI(DataTable dict) { isFold = EditorGUILayout.Foldout(isFold, "新增记录"); if (isFold) { EditorGUI.indentLevel++; string key = dict.TableKeys[0]; AddDataPos = EditorGUILayout.BeginScrollView(AddDataPos, GUILayout.ExpandHeight(false)); EditorGUILayout.LabelField("<主键>字段名", key); mianKey = EditorUtilGUI.FieldGUI_TypeValue(FieldType.String, mianKey,null); if (mianKey == "") { EditorGUILayout.LabelField("主键不能为空!"); } else if (dict.ContainsKey(mianKey)) { EditorGUILayout.LabelField("重复的主键!"); } EditorGUILayout.Space(); EditorDataGUI(dict, content); if (!dict.ContainsKey(mianKey) && mianKey != "") { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("新增", GUILayout.Width(position.width - 60))) { content.Add(key, mianKey); m_currentData.AddData(content); content = new SingleData(); mianKey = ""; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.Space(); } }
public static string FieldGUI_TypeValue(FieldType type, string content, string enumType) { SingleField data = new SingleField(type, content, enumType); return(EditorUtilGUI.FieldGUI_TypeValue(data)); }
SingleData EditorDataGUI(DataTable table, SingleData data) { try { List <string> keys = table.TableKeys; for (int i = 0; i < keys.Count; i++) { string keyTmp = keys[i]; FieldType type = table.GetFieldType(keyTmp); if (i != 0) { bool cancelDefault = false; EditorGUILayout.BeginHorizontal(); if (data.ContainsKey(keyTmp)) { EditorGUILayout.LabelField("[" + keyTmp + "]"); if (GUILayout.Button("使用默认值")) { data.Remove(keyTmp); EditorGUILayout.EndHorizontal(); continue; } } else { EditorGUILayout.LabelField("[" + keyTmp + "] (默认值)"); if (GUILayout.Button("取消默认值")) { cancelDefault = true; } } EditorGUILayout.EndHorizontal(); //EditorGUI.indentLevel++; EditorGUI.indentLevel++; //非默认值情况 if (data.ContainsKey(keyTmp)) { EditorGUILayout.LabelField("字段名", keyTmp); EditorGUILayout.LabelField("注释", table.GetNote(keyTmp)); string newContent = EditorUtilGUI.FieldGUI_TypeValue(type, data[keyTmp], table.GetEnumType(keyTmp)); if (newContent != data[keyTmp]) { data[keyTmp] = newContent; } } //如果是默认值则走这里 else { EditorGUILayout.LabelField("字段名", keyTmp); EditorGUILayout.LabelField("注释", table.GetNote(keyTmp)); string newContent = ""; if (table.m_defaultValue.ContainsKey(keyTmp)) { newContent = new SingleField(type, table.GetDefault(keyTmp), table.GetEnumType(keyTmp)).m_content; } else { newContent = new SingleField(type, null, table.GetEnumType(keyTmp)).m_content; } if (type != FieldType.Enum) { EditorGUILayout.LabelField("字段类型", type.ToString()); } else { EditorGUILayout.LabelField("字段类型", type.ToString() + "/" + table.GetEnumType(keyTmp)); } EditorGUILayout.LabelField("(默认)字段内容", new SingleField(type, newContent, table.GetEnumType(keyTmp)).GetShowString()); if (cancelDefault) { data.Add(keyTmp, newContent); } } EditorGUI.indentLevel--; //EditorGUI.indentLevel--; } EditorGUILayout.Space(); } } catch (Exception e) { EditorGUILayout.TextArea(e.ToString(), EditorGUIStyleData.s_ErrorMessageLabel); } return(data); }
SingleData EditorDataGUI(DataTable table, SingleData data) { List <string> keys = table.TableKeys; for (int i = 0; i < keys.Count; i++) { string keyTmp = keys[i]; FieldType type = table.GetFieldType(keyTmp); if (i != 0) { if (data.ContainsKey(keyTmp)) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("字段名", keyTmp); if (GUILayout.Button("使用默认值")) { data.Remove(keyTmp); EditorGUILayout.EndHorizontal(); continue; } EditorGUILayout.EndHorizontal(); string newContent = EditorUtilGUI.FieldGUI_TypeValue(type, data[keyTmp]); if (newContent != data[keyTmp]) { data[keyTmp] = newContent; } } else { bool cancelDefault = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("字段名", keyTmp); if (GUILayout.Button("取消默认值")) { cancelDefault = true; } EditorGUILayout.EndHorizontal(); string newContent = ""; if (table.m_defaultValue.ContainsKey(keyTmp)) { newContent = new SingleField(type, table.GetDefault(keyTmp)).m_content; } else { newContent = new SingleField(type, null).m_content; } EditorGUILayout.LabelField("字段类型", type.ToString()); EditorGUILayout.LabelField("(默认值)字段内容", new SingleField(type, newContent).GetShowString()); if (cancelDefault) { data.Add(keyTmp, newContent); } } } EditorGUILayout.Space(); } return(data); }