unreal slate 创建 window

时间:2021-08-07 05:45:38

testWindow = SNew(SWindow) .Title(LOCTEXT("Asset Window", "Asset Window")) .ClientSize(FVector2D(30, 20)) .SupportsMaximize(false) .SupportsMinimize(false) .SizingRule(ESizingRule::Autosized) .AutoCenter(EAutoCenter::None) .IsInitiallyMaximized(false) .bDragAnywhere(true) [ textBlock.ToSharedRef() ]; TSharedPtr<SWindow> TopWindow = FSlateApplication::Get().GetActiveTopLevelWindow(); if (TopWindow.IsValid()) { //Add as Native FSlateApplication::Get().AddWindowAsNativeChild(testWindow.ToSharedRef(), TopWindow.ToSharedRef(), true); } else { //Default in case no top window FSlateApplication::Get().AddWindow(testWindow.ToSharedRef()); } GEngine->GameViewport->AddViewportWidgetContent(SNew(SWeakWidget).PossiblyNullContent(testWindow.ToSharedRef()));

  代码片段。备用。

unreal slate 创建 window