Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@unwitherer
Created July 17, 2017 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unwitherer/d1319a8f7277ae0cfd93e74a94514f86 to your computer and use it in GitHub Desktop.
Save unwitherer/d1319a8f7277ae0cfd93e74a94514f86 to your computer and use it in GitHub Desktop.
// .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