docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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:

    1. Subclass DrawingVisualizer<T> and override Draw. This is the quickest path for most message types.

      For full control over the IVisual, subclass BaseVisualFactory<T> directly instead, as in ExampleVisualizers/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
          }
      }
      
    2. Add the component to a GameObject that can find an IConnector.

    3. Leave Topic blank to make it the default for every PoseMsg topic, 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.

    Additional resources

    • Introduction to visualization
    • Drawing 3D utility reference
    • Enable visualizations
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)