I have a widget blueprint that i want to add to a pawn as a UI element. I can do this in blueprints by adding a 3d widget component and setting its class to my widget blueprint. I want to do this in C++, however. I have the widget component up but I am trying to set its class to the widget blueprint reference and I seem to be having issues with that. I need this to be a 3d widget since this is for VR.
Here is what I have now.
.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
class UWidgetComponent* CoolWidget;
.cpp constructor
static ConstructorHelpers::FObjectFinder<TSubclassOf<UUserWidget>> Cool_use(TEXT("WidgetBlueprint'/Game/Blueprints/Panel_Cool.Panel_Cool'"));
if (Cool_use.Succeeded()) {
CoolWidget->SetWidgetClass(*Cool_use.Object);
}
This crashes the game engine, when I take away the pointer from Cool_use.Object the error I get is that it cannot convert TSubClassOf * to TSubClassOf. When I keep it, the error is that to see reference to function template instantiation.
The question I have is very straightforward. How do I properly set the Widget Class to a widget blueprint reference?
Thanks!