private static void ExecuteCustomTool() { CustomTools.Clear(); List <Type> types = EditorReflectionToolkit.GetTypesInEditorAssemblies(); for (int i = 0; i < types.Count; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); for (int j = 0; j < methods.Length; j++) { if (methods[j].IsDefined(typeof(CustomToolAttribute), false)) { CustomTools.Add(methods[j]); } } } if (CustomTools.Count <= 0) { Log.Warning("当前不存在至少一个自定义工具!为任何处于 Editor 文件夹中的类的无参静态函数添加 CustomTool 特性,可将该函数附加至自定义工具菜单!"); } else { for (int i = 0; i < CustomTools.Count; i++) { CustomTools[i].Invoke(null, null); } Log.Info("已执行 " + CustomTools.Count + " 个自定义工具!"); CustomTools.Clear(); } }
protected override void OnEnable() { base.OnEnable(); _settingItems.Clear(); _settingItems.Add(new SettingItemMain()); _settingItems.Add(new SettingItemAspectTrack()); _settingItems.Add(new SettingItemAudio()); _settingItems.Add(new SettingItemController()); _settingItems.Add(new SettingItemWebRequest()); _settingItemSigns.Clear(); _settingItemSigns.Add(true); _settingItemSigns.Add(true); _settingItemSigns.Add(true); _settingItemSigns.Add(true); _settingItemSigns.Add(true); List <Type> types = EditorReflectionToolkit.GetTypesInEditorAssemblies(type => { return(type.IsSubclassOf(typeof(SettingItemBase)) && type.GetCustomAttribute <InternalSettingItemAttribute>() == null); }); for (int i = 0; i < types.Count; i++) { _settingItems.Add(Activator.CreateInstance(types[i]) as SettingItemBase); _settingItemSigns.Add(false); } for (int i = 0; i < _settingItems.Count; i++) { _settingItems[i].OnBeginSetting(); } _resetGUIContent = new GUIContent(); _resetGUIContent.image = EditorGUIUtility.IconContent("_Popup").image; _resetGUIContent.tooltip = "Menu"; _editGUIContent = new GUIContent(); _editGUIContent.image = EditorGUIUtility.IconContent("d_editicon.sml").image; _editGUIContent.tooltip = "Edit Module"; _currentItem = -1; _itemFilter = ""; }
/// <summary> /// LnkTools初始化 /// </summary> private static void OnInitLnkTools() { IsEnableLnkTools = EditorPrefs.GetBool(EditorPrefsTable.LnkTools_Enable, false); IsExpansionLnkTools = EditorPrefs.GetBool(EditorPrefsTable.LnkTools_Expansion, false); if (IsEnableLnkTools) { LnkToolss.Clear(); List <Type> types = EditorReflectionToolkit.GetTypesInEditorAssemblies(); for (int i = 0; i < types.Count; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); for (int j = 0; j < methods.Length; j++) { if (methods[j].IsDefined(typeof(LnkToolsAttribute), false)) { LnkToolsAttribute attribute = methods[j].GetCustomAttribute <LnkToolsAttribute>(); LnkTools lnkTools = new LnkTools(attribute.Tooltip, attribute.Priority, methods[j]); LnkToolss.Add(lnkTools); } } } LnkToolss.Sort((x, y) => { if (x.Priority < y.Priority) { return(-1); } else if (x.Priority == y.Priority) { return(0); } else { return(1); } }); SceneView.onSceneGUIDelegate += OnLnkToolsGUI; } }