Sure, my use case is quite straight-forward. I have created a library class in C++, like this:
UCLASS()
class GLOW_API UMyStaticToolkit : public UObject
{
GENERATED_BODY()
public:
static void SetActorDebugText(UWorld* World, AActor* Actor, FString String, FColor Color = FColor::White);
};
The implementation of this class looks like this:
void UMyStaticToolkit::SetActorDebugText(UWorld* World, AActor* Actor, FString String, FColor Color)
{
AHUD* HUD = World->GetFirstPlayerController()->GetHUD();
float width = 0.0f, height = 0.0f;
if(GEngine != nullptr)
{
HUD->GetTextSize(String, width, height, GEngine->GetMediumFont());
PrintString(FString::SanitizeFloat(width)); // this prints out "0"
}
HUD->RemoveDebugText(Actor);
HUD->AddDebugText(String, Actor, -1.0f, FVector(0.0f, 0.0f, 100.0f), FVector(0.0f, 0.0f, 100.0f), Color, true, false, true);
}
Now I simply call this static method UMyStaticToolkit::SetActorDebugText() from other places in my C++ code in order to print some debug text above the head of my actor(s). This works, text is being rendered. However, the width returned by GetTextSize() is always 0 …