void ShowInfoGUI(Type type, PropertyInfo[] infos) { ShowInfoGUI(infos, ref selectP, (f) => { return(ReflectionToCodeDefineInfo.GetPropertyInfoToDeclaring(type, f)); }, (f) => { ShowFieldANDPropertyInfo(f); }); }
void ShowInfoGUI(Type type, MethodInfo[] infos) { ShowInfoGUI(infos, ref selectM, (f) => { return(ReflectionToCodeDefineInfo.GetMethodInfoToDeclaring(type, f)); }, (f) => { ShowFieldANDPropertyInfo(f, () => { ParameterInfo[] pis = f.GetParameters(); string ss = ""; for (int i = 0; i < pis.Length; i++) { Type tt = pis[i].ParameterType; ss += (string.IsNullOrEmpty(tt.FullName)) ? tt.ToString() : tt.FullName; if (i < (pis.Length - 1)) { ss += ","; } } GUILayout.Space(5); ShowLabel("参数信息", ss); for (int i = 0; i < pis.Length; i++) { ParameterInfo tt = pis[i]; ShowLabel("参数" + i, tt.Name); ShowFieldANDPropertyInfo(tt); GUILayout.Space(6); } MethodInfo m = f.GetBaseDefinition(); if (!f.Equals(m)) { GUILayout.Space(10); ShowLabel("父方法", ReflectionToCodeDefineInfo.GetMethodInfoToDeclaring(type, m)); ShowFieldANDPropertyInfo(m); } }); }, (f) => { if (type.IsAbstract || type.IsInterface) { return; } if (GUILayout.Button("调用测试")) { ReflectionTestMethodRunnerWindow.AddTest(selectCont.data, f); } }); }
void ShowInfoGUI(Type type, ConstructorInfo[] infos) { ShowInfoGUI(infos, ref selectC, (f) => { return(ReflectionToCodeDefineInfo.GetConstructorInfoToDeclaring(type, f)); }, (f) => { ShowFieldANDPropertyInfo(f, () => { ParameterInfo[] pis = f.GetParameters(); string ss = ""; for (int i = 0; i < pis.Length; i++) { Type tt = pis[i].ParameterType; ss += (string.IsNullOrEmpty(tt.FullName)) ? tt.ToString() : tt.FullName; if (i < (pis.Length - 1)) { ss += ","; } } GUILayout.Space(5); ShowLabel("参数信息", ss); for (int i = 0; i < pis.Length; i++) { ParameterInfo tt = pis[i]; ShowLabel("参数" + i, tt.Name); ShowFieldANDPropertyInfo(tt); GUILayout.Space(6); } //MethodInfo m = f.get (); //if (!f.Equals(m)) //{ // GUILayout.Space(10); // ShowLabel("父方法", ReflectionToCodeDefineInfo.GetMethodInfoToDeclaring(type, m)); // ShowPropertyInfo(m); //} }); }); }
void OnGUI() { assemblyName = EditorDrawGUIUtil.DrawBaseValue("程序集名:", assemblyName).ToString(); typeFullName = EditorDrawGUIUtil.DrawBaseValue("类型全名:", typeFullName).ToString(); if (GUILayout.Button("获取全部信息")) { AddType(assemblyName, typeFullName); } GUILayout.BeginVertical(); selectCont = EditorDrawToolBarGUI.DrawToolBar(ref posS, scriptsNames, selectCont, (tt) => { GetTypeAllInfo(tt.data); }); Type ac = null; if (selectCont != null) { ac = selectCont.data; } if (ac == null || fields == null) { return; } toolbarOption = GUILayout.Toolbar(toolbarOption, toolbarTexts, GUILayout.Width(Screen.width)); switch (toolbarOption) { case 0: string content = ReflectionToCodeDefineInfo.GetTypeAllInfo(ac, constructorInfos, fields, propertyInfos, methodInfos); GUILayout.Space(6); pos = EditorGUILayout.BeginScrollView(pos); GUILayout.BeginVertical("NotificationBackground"); List <string> sList = new List <string>(); int size = content.Length; int everyDrawSize = 5000; while (size >= everyDrawSize) { string subs = content.Substring(0, everyDrawSize); content = content.Remove(0, everyDrawSize); int id = content.IndexOf("\n"); subs += content.Substring(0, id + 1); content = content.Remove(0, id + 1); size = content.Length; sList.Add(subs); } if (content.Length > 0) { sList.Add(content); } for (int i = 0; i < sList.Count; i++) { GUIStyle style1 = new GUIStyle("Label"); style1.richText = true; style1.fontSize = 15; EditorGUILayout.TextArea(sList[i], style1); } GUILayout.EndVertical(); break; case 1: GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); toolbarOptionSec = GUILayout.Toolbar(toolbarOptionSec, toolbarTextsSec, GUILayout.Width(Screen.width - 40)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); pos = EditorGUILayout.BeginScrollView(pos); switch (toolbarOptionSec) { case 0: GUILayout.Space(6); ShowMainType(ac); break; case 1: GUILayout.Space(6); ShowInfoGUI(ac, constructorInfos); break; case 2: GUILayout.Space(6); ShowInfoGUI(ac, fields); break; case 3: GUILayout.Space(6); ShowInfoGUI(ac, propertyInfos); break; case 4: GUILayout.Space(6); ShowInfoGUI(ac, methodInfos); break; } break; case 2: break; } GUILayout.FlexibleSpace(); EditorGUILayout.EndScrollView(); GUILayout.EndVertical(); }