Component visualizers let you easily draw gizmos for your components. This can be handy when you need to display some kind of visual indication of what the component is going to do to aid in level design or debugging purposes.

Adding component visualizers is a two step process:

  1. Create the visualizer class
  2. Register the visualizer

Create the visualizer class

class MYEDITOR_API FMyComponentVisualizer : public FComponentVisualizer
	virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override;
void FMyComponentVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI)
	//Get a ref to the component being visualized to get information from it
	auto* Comp = Cast<UMyComponent>(Component);
	//Draw the viaualization
	const FTransform Transform = FTransform(Comp->GetSomeDirection(), Comp->GetOwner()->GetActorLocation());
	DrawDirectionalArrow(PDI, Transform.ToMatrixNoScale(), FLinearColor::Red, 50, 10, 0, 1);

A number of different functions exist for drawing visualizers. Most of them are in SceneManagement.h in the engine.

Register the visualizer

You need to register the visualizer in an Editor Module

//Place this in your StartupModule
GUnrealEd->RegisterComponentVisualizer(UMyComponent::StaticClass()->GetFName(), MakeShareable(new FMyComponentVisualizer()));