Hello,
I’m trying to create an FCanvas by using the game viewport as a render target and have it display a string like so:
UWorld* WorldContext = WorldContextObject->GetWorld();
FCanvas DebugCanvas(GEngine->GameViewport->GetGameViewport(), nullptr, WorldContext, WorldContext ? WorldContext->FeatureLevel : GMaxRHIFeatureLevel);
DebugCanvas.SetAllowSwitchVerticalAxis(false);
DebugCanvas.SetRenderTargetRect(FIntRect(0,0,2000, 1200));
FCanvasTextItem MessageTextItem(FVector2D(0, 0), FText::GetEmpty(), GEngine->GetSmallFont(), FLinearColor::White);
MessageTextItem.EnableShadow(FLinearColor::Black);
MessageTextItem.Text = FText::FromString(message);
MessageTextItem.SetColor(FLinearColor::Blue);
MessageTextItem.Scale = FVector2D::UnitVector;
DebugCanvas.DrawItem(MessageTextItem, FVector2D(300, 300));
DebugCanvas.Flush_GameThread();
Unfortunately I am not seeing anything being displayed and I have no idea why. This whole snipped is called each tick. I know I can probably create my own HUD class and have it run over over there but I wanted to see if I can do it in another way.