You can use the debug draw service to draw debug shapes similar to calling functions like DrawDebugBox
or DrawDebugSphere
.
An additional benefit of using this is it uses a UCanvas directly. This allows you to do better text rendering and some other more advanced uses. You can also control when the debug drawing is enabled via ShowFlags.
Usage
Register a delegate with the service:
DebugDrawHandle = UDebugDrawService::Register(TEXT("Navigation"), FDebugDrawDelegate::CreateUObject(this, &ThisClass::DebugDraw));
The first parameter is the name of the ShowFlag which controls when to call the delegate. In this example, the DebugDraw
function is only called when the Navigation debug ShowFlag is enabled.
(See ShowFlags for how to create your own)