-
-
Save unwitherer/d1319a8f7277ae0cfd93e74a94514f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .h | |
#pragma once | |
#include "CoreMinimal.h" | |
#include "Kismet/BlueprintFunctionLibrary.h" | |
#include "BPFL_AddWindow.generated.h" | |
UCLASS() | |
class BLOGTEST416B_API UBPFL_AddWindow : public UBlueprintFunctionLibrary | |
{ | |
GENERATED_BODY() | |
public: | |
UFUNCTION(BlueprintCallable, Category = "Slate", meta = (HidePin = "worldContextObject_", DefaultToSelf = "worldContextObject_")) | |
static void AddWindow(UObject* worldContextObject_); | |
}; | |
// .cpp | |
#include "BPFL_AddWindow.h" | |
#include "Engine.h" | |
#include "SWindow.h" | |
#include "SlateApplication.h" | |
#define LOCTEXT_NAMESPACE "BPFL_AddWidget" | |
void UBPFL_AddWindow::AddWindow(UObject* worldContextObject_) | |
{ | |
TSharedRef<SWindow> window = SNew(SWindow) | |
.Title(LOCTEXT("CreateWindow", "Test Slate Window")) | |
.ClientSize(FVector2D(512.0f, 512.0f)) | |
[ | |
SNew(SVerticalBox) | |
+ SVerticalBox::Slot() | |
.VAlign(VAlign_Center) | |
.HAlign(HAlign_Center) | |
[ | |
SNew(SButton) | |
.Text(LOCTEXT("CreateButton", "Push Me!")) | |
] | |
]; | |
FSlateApplication::Get().AddWindowAsNativeChild(window, GEngine->GameViewport->GetWindow().ToSharedRef(), true); | |
window->ShowWindow(); | |
} | |
#undef LOCTEXT_NAMESPACE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment