Write a custom visualizer
Create a visualizer for a message type that doesn't have a built-in one.
Create the visualizer
To create a visualizer for a message type:
Subclass
DrawingVisualizer<T>and overrideDraw. This is the quickest path for most message types.For full control over the
IVisual, subclassBaseVisualFactory<T>directly instead, as inExampleVisualizers/PrefabVisualizerExample.cs:public class PrefabVisualizerExample : BaseVisualFactory<PoseMsg> { public GameObject prefab; // shows up in the Inspector protected override IVisual CreateVisual(string topic) => new PrefabVisual(ConnectorInjector.FindConnector(gameObject), topic, prefab); // Adds a "3D" checkbox for this visualizer in the Topics tab public override bool CanShowDrawing => true; class PrefabVisual : IVisual { public PrefabVisual(IConnector connector, string topic, GameObject prefab) => connector.Subscribe<PoseMsg>(topic, AddMessage); // subscribe here // ... store the message, and implement // IsDrawingEnabled / SetDrawingEnabled / Redraw / OnGUI } }Add the component to a GameObject that can find an
IConnector.Leave Topic blank to make it the default for every
PoseMsgtopic, or set a topic to scope it to that topic only.
On Start(), BaseVisualFactory<T> registers itself with VisualFactoryRegistry, and the visualizer appears in the Topics tab. For DrawingVisualizer<T> and history-style examples, refer to PointVisualizerExample and PointTracingVisualizerExample in the same folder.