I am trying to use a UserWidget blueprint as my HUD. Nevertheless, “CreateWidget” is marked as an undeclared identifier. Why could that be? I already added UMG, Slate, and SlateCore dependency modules.
The following is in my header file:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HUD")
TSubclassOf<class UUserWidget>HUDWidgetClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HUD")
class UUserWidget* HUDWidget;
The following is in my .cpp file inside the BeginPlay() function:
if (HUDWidgetClass){
HUDWidget = CreateWidget<UUserWidget>(this, HUDWidgetClass);
HUDWidget->AddToViewport();
HUDWidget->SetVisibility(ESlateVisibility::Visible);
}