|
专栏目录:
<hr/>MenuBar菜单栏扩展可以有效的组合我们对编辑器的扩展功能,把我们写好的一系列功能整合到一个独立的菜单栏,显得更加规整,参考环境UE4.26
- 示例代码
- 获取LevelEditor模块并添加菜单栏扩展的绑定事件
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked< FLevelEditorModule >(&#34;LevelEditor&#34;);
TSharedRef<FExtender> MenuBarExtender = MakeShared<FExtender>();
MenuBarExtender->AddMenuBarExtension(&#34;Help&#34;, EExtensionHook::After, PluginCommands, FMenuBarExtensionDelegate::CreateRaw(this, &FSimpleEditorsModule::AddMenuBarExtension));
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuBarExtender);
}
void FSimpleEditorsModule::AddMenuBarExtension(FMenuBarBuilder &Builder)
{
Builder.AddPullDownMenu(
LOCTEXT(&#34;CUSTOMTOOLS&#34;, &#34;Tools&#34;),
LOCTEXT(&#34;I AM TOOL&#34;, &#34;I am tool&#34;),
FNewMenuDelegate::CreateRaw(this, &FSimpleEditorsModule::PullDwonBar),
&#34;Tools&#34;);
}
void FSimpleEditorsModule::PullDwonBar(FMenuBuilder& Builder)
{
Builder.AddMenuEntry(FSimpleEditorsCommands::Get().PluginAction);
Builder.BeginSection(TEXT(&#34;Others&#34;));
{
Builder.AddWidget(
SNew(SImage),
LOCTEXT(&#34;IamgeWidget&#34;, &#34;Iamge widget&#34;)
);
Builder.AddEditableText(
LOCTEXT(&#34;EditableText&#34;, &#34;EditableText&#34;),
LOCTEXT(&#34;EditableText_Tips&#34;, &#34;EditableText_Tips&#34;),
FSlateIcon(),
LOCTEXT(&#34;Text&#34;, &#34;Hello World!!!&#34;)
);
}
Builder.EndSection();
Builder.AddMenuSeparator();
Builder.AddMenuEntry(FSimpleEditorsCommands::Get().PluginAction);
Builder.AddMenuEntry(FSimpleEditorsCommands::Get().PluginAction);
}
- 补充说明
- Builder.AddSubMenu(); 可以扩展下拉菜单的子菜单
- FExtender类的AddMenuBarExtension可以扩展菜单栏;AddMenuExtension可以扩展菜单;AddToolBarExtension可以用来扩展工具栏菜单
NEXT: |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|