I created my own stack from a UObject and just added the widget to the viewport using a different ZOrder like this. Works great. Wish there was an easier way, but it’s not too bad.
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "CommonActivatableWidget.h"
#include "UIStack.generated.h"
UCLASS(BlueprintType)
class TOWERDEFENSE_API UUIStack : public UObject
{
GENERATED_BODY()
UPROPERTY()
TArray<TObjectPtr<UCommonActivatableWidget>> Stack;
UFUNCTION(BlueprintCallable)
void PushWidget(UCommonActivatableWidget *Widget);
UFUNCTION(BlueprintCallable)
void PopWidget();
};
#include "UIStack.h"
void UUIStack::PushWidget(UCommonActivatableWidget* Widget)
{
if (!Stack.IsEmpty())
{
Stack[Stack.Num()-1]->DeactivateWidget();
}
Stack.Add(Widget);
Widget->AddToViewport(Stack.Num());
Widget->ActivateWidget();
}
void UUIStack::PopWidget()
{
if (!Stack.IsEmpty())
{
UCommonActivatableWidget* Widget = Stack[Stack.Num()-1];
Widget->DeactivateWidget();
Widget->RemoveFromParent();
Stack.RemoveAt(Stack.Num()-1);
}
if (!Stack.IsEmpty())
{
UCommonActivatableWidget* Widget = Stack[Stack.Num() - 1];
Widget->ActivateWidget();
}
}
So you have to create the widget yourself and then add it.
So you just need to create the stack somewhere that’s accessible and call PushWidget and PopWidget. I have a global GameActor blueprint that accissible from anywhere.
Leaving this here in case someone else needs it.
I’m now looking to see if there’s a way to blur the background while a popup is on screen.