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); }
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) { 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; }