Macro’s are just simple text replacement. You don’t “return” anything.
This is an example of what that would expand to
Compiler Explorer
Macros are best avoided and this can easily be a template instead
template<class UMGClass>
UMGClass* OpenWidget(TSubclassOf<UUserWidget> WBP_Class)
{
UMGClass* UI = CreateWidget<UMGClass>(GetWorld(), WBP_Class);
if (UI)
{
UI->SetupWidget();
}
return UI;
}
// Used like
UUserWidget* Thing = OpenWidget<UUserWidget>(WBP_MyWidget);