UE4 Editor Plugin UI - 模态对话框
开发UE4 Editor插件的时候往往需要一些交互式界面,对话框必不可少。
Slate Dialog
SH3DOptionsWindow
继承自SCompoundWidget
实现了对话框中的UI内容。具体可参考源码:Engine\Plugins\Enterprise\DatasmithImporter\Source\DatasmithImporter\Private\UI\DatasmithImportOptionsWindow.cpp
#include "Interfaces/IMainFrameModule.h"
#include "UI/SH3DOptionsWindow.h"
//测试模态窗口
TSharedPtr<SWindow> ParentWindow;
if (FModuleManager::Get().IsModuleLoaded("MainFrame"))
{
IMainFrameModule& MainFrame = FModuleManager::LoadModuleChecked<IMainFrameModule>("MainFrame");
ParentWindow = MainFrame.GetParentWindow();
}
TSharedRef<SWindow> Window = SNew(SWindow)
.Title(LOCTEXT("H3DImportSettingsTitle", "H3D Import Options"))
.SizingRule(ESizingRule::Autosized);
TSharedPtr<SH3DOptionsWindow> H3DOptionsWindow;
Window->SetContent
(
SAssignNew(H3DOptionsWindow, SH3DOptionsWindow)
.WidgetWindow(Window)
);
FSlateApplication::Get().AddModalWindow(Window, ParentWindow, false);