Why doesn't the Unreal Engine have Draw Debug functions in screen space?

Does anyone know, why the Unreal Engine doesn’t have Draw Debug functions for screen space?

There is the draw debug circle, capsule, box, line, and many other functions/events. But they’re all drawing these shapes in the 3D space. Why isn’t there something similar for 2D screen space? Where you enter pixel coordinates as input, and the shape gets drawn at that location.

You can use the AHUD and UCanvas functions (DrawLine, DrawRect) to draw shapes in screen space. It’s not the same as using the Draw Debug functions, but it works for most tasks.

Yes, but you only have the Draw Line and Draw Rect, there is no draw circle or ellipse. You don’t have much control over it, and you can only use it within the HUD blueprint, as far as I’m aware. It’s not possible to call such functions inside your actors.

There are also DrawDebugCanvas2DCircle, DrawDebugCanvas2DBox etc. Check DrawDebugHelpers.h
And there are many ways to use UCanvas: AHUD::OnHUDPostRender delegate, UDebugDrawService, AActor::PostRenderFor.

Hi, thanks for the answer. This seems like something I’m looking for.

When using functions like DrawDebugCanvas2DCircle, it requires a UCanvas argument. Do you know how can I get reference to it?

image

if you are overriding the huds DrawHUD method then you can access it’s canvas directly through it’s variable called Canvas.

example

.h in custom hud class derived from AHUD

virtual void DrawHUD() override;

.cpp

void ACustomHUD::DrawHUD() {
DrawDebugCanvas2DCircle(Canvas, FVector2D(400, 400), 200, 30, FLinearColor::Red, 6);
}