Use FObjectFinder with TSubClassof variable?

When I tried to use UMG in C++ I could make it work loading its class inside constructor this way:


static ConstructorHelpers::FObjectFinder<UClass> ErrWdgtCntnt(TEXT("/Game/UI/Widgets/Common/WGT_Warning.WGT_Warning_C"));
ErrorDialogWidget = ErrWdgtCntnt.Object;

and this way outside constructor:


ErrorDialogWidget = StaticLoadClass(UObject::StaticClass(), nullptr, TEXT("/Game/UI/Widgets/Common/WGT_Warning.WGT_Warning_C"));
UUserWidget * HUD = CreateWidget<UUserWidget>(GetWorld(), ErrorDialogWidget);

Cheers

2 Likes