Hello, how to construct a widget and then push it to a layer stack in common UI? My concern is that “Exposed on spawn” variables are not showing up when pushing a widget.
PS: Came up with a solution. Made a custom CommonActivatableWidgetStack class and added a new function called “PushWidgetInstance”, which I can use to push my constructed widgets to the stack. I hope it helps anyone with the same problem.
.h
UFUNCTION(BlueprintCallable, Category = ActivatableWidgetStack, meta = (DeterminesOutputType = WidgetInstance))
UCommonActivatableWidget* PushWidgetInstance(UCommonActivatableWidget* WidgetInstance, bool& success);
.cpp
#include "CommonActivatableStack_Custom.h"
#include "CommonActivatableWidget.h"
UCommonActivatableWidget* UCommonActivatableStack_Custom::PushWidgetInstance(UCommonActivatableWidget* WidgetInstance, bool& success)
{
if (ensure(!WidgetList.Contains(WidgetInstance)))
{
WidgetList.Add(WidgetInstance);
OnWidgetAddedToList(*WidgetInstance);
if (WidgetInstance != nullptr) {
success = true;
}
}
else
{
// Optionally, perform additional actions here
success = false;
}
return WidgetInstance;
}
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.