I still couldn’t figure it out so here I am with my question:
//in my constructor
static ConstructorHelpers::FObjectFinder<UFont> HUDFontOb(TEXT("Font'/Game/Fonts/NewFont.NewFont'"));
HUDFont = HUDFontOB.Object;
//in the header of my HUD class
UPROPERTY()
UFont* HUDFont;
I’ve got the Font in the ContentBrowser in a folder named Fonts.
It seems to me that this a Path problem in the TEXT(), I got the same error message whatever I write in TEXT(), still I can’t figure it out, I hope someone will be able to enlighten me on this issue.
Get myself to simply use BluePrints to set the Default font to do that add into GameMode class :
#include "Engine/Blueprint.h"
//into your constructor
static ConstructorHelpers::FObjectFinder<UBlueprint> HUDBpClass(TEXT("Blueprint'/Game/Blueprints/BP_HUD.BP_HUD'"));
if (HUDBpClass.Object != NULL)
{
HUDClass = (UClass*) HUDBpClass.Object->GeneratedClass;
}
BP_HUD is a blueprint instance of your HUD class in C ++, don’t forget to change UPROPERTY to something like that: UPROPERTY(EditDefaultsOnly, BlueprintReadWrtie, Category = HUDFont)