public static void DrawSelect(TableConfig config, PropertyInfo f, object o) { List <double> selectValue = (List <double>)f.GetValue(o); GUILayout.BeginHorizontal(GUILayout.Width(100)); GUILayout.Label(config.Des, GUILayout.Width(100)); string selects = Editor_TableTool.Join(selectValue); GUILayout.Label(selects, GUILayout.Width(100)); if (GUILayout.Button("选择", GUILayout.Width(50))) { Type t = GetTypeByName(config.ParameterList[0]); MethodInfo selectMethod = t.GetMethod(config.ParameterList[1]); selectMethod.Invoke(null, new object[] { o }); } GUILayout.EndHorizontal(); }
public static void DrawDisplayWindow(object o) { Type t = o.GetType(); PropertyInfo[] fs = t.GetProperties(); Dictionary <string, TableConfig> classDic = Editor_TableTool.GetClassDrawConfig(t.Name); if (classDic == null) { return; } for (int i = 0; i < fs.Length; i++) { PropertyInfo f = fs[i]; TableConfig config; if (!classDic.TryGetValue(f.Name, out config)) { Debug.LogError("警告 " + f.Name + " 没有配置tableconfig项"); return; } if (config.AttributeType == "InputAttribute") { EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, f.GetValue(o))); } else if (config.AttributeType == "ListGroupAttribute") { Type type = f.PropertyType.GetGenericArguments()[0]; if (type.Equals(typeof(string))) { List <string> value = (List <string>)f.GetValue(o); EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, Editor_TableTool.Join(value))); } else if (type.Equals(typeof(double))) { List <double> value = (List <double>)f.GetValue(o); EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, Editor_TableTool.Join(value))); } } else if (config.AttributeType == "SelectAttribute") { List <double> value = (List <double>)f.GetValue(o); EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, Editor_TableTool.Join(value))); } else if (config.AttributeType == "VariableListAttribute") { EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, f.GetValue(o))); } else if (config.AttributeType == "ChildAttribute") { Type type = f.PropertyType.GetGenericArguments()[0]; if (type.Equals(typeof(string))) { List <string> value = (List <string>)f.GetValue(o); EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, Editor_TableTool.Join(value))); } else if (type.Equals(typeof(double))) { List <double> value = (List <double>)f.GetValue(o); EditorGUILayout.LabelField(string.Format("{0}:{1}", config.Des, Editor_TableTool.Join(value))); } } } }