I won’t go into the plug-in creation part and just show the picture.
Next is the code part
Tool.app section
#include"EditorAssetLibrary.h"#include"Blutility/Classes/EditorUtilityWidget.h"#include"UMGEditor/Public/WidgetBlueprint.h"#include"EditorUtilityWidgetBlueprint.h"#include"EditorUtilitySubsystem.h"voidFToolModule::StartupModule(){
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-moduleFToolStyle::Initialize();FToolStyle::ReloadTextures();FToolCommands::Register();
PluginCommands =MakeShareable(new FUICommandList);
PluginCommands->MapAction(FToolCommands::Get().OpenPluginWindow,FExecuteAction::CreateRaw(this,&FToolModule::StartToolWidget),FCanExecuteAction());UToolMenus::RegisterStartupCallback(
FSimpleMulticastDelegate::FDelegate::CreateRaw(this,&FToolModule::RegisterMenus));FGlobalTabmanager::Get()->RegisterNomadTabSpawner(ToolTabName,FOnSpawnTab::CreateRaw(this,&FToolModule::OnSpawnPluginTab)).SetDisplayName(LOCTEXT("FToolTabTitle","Tool")).SetMenuType(ETabSpawnerMenuType::Hidden);}//注释掉不用的方法// void FToolModule::PluginButtonClicked()// {
// FGlobalTabmanager::Get()->TryInvokeTab(ToolTabName);// }
voidFToolModule::RegisterMenus(){
// Owner will be used for cleanup in call to UToolMenus::UnregisterOwner
FToolMenuOwnerScoped OwnerScoped(this);
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
TSharedPtr<FExtender> ToolbarExtender =MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension("Settings", EExtensionHook::After, PluginCommands,FToolBarExtensionDelegate::CreateRaw(this,&FToolModule::AddToolbarExtension));
LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender);}
PrivateDependencyModuleNames.AddRange(new string[]{
..."EditorScriptingUtilities","Blutility","UMGEditor"// ... add private dependencies that you statically link with here ... });