Enable visualizations
Turn 2D and 3D visualizations on and off from the Topics tab or from code.
You can enable a visualization interactively from the Topics tab, or drive it from code. Both methods work with any topic that has a registered visualizer.
Note
The Visualizations subsystem is not compatible with Distributed Rendering. When the UNITY_SIMULATIONPRO_DISTRIBUTED_RENDERING define is active and distribution is enabled, VisualizationTopicsTab logs an error and disables itself.
Enable a visualization
To enable a visualization from the Topics tab:
- Add a
VisualizationTopicsTabcomponent to a GameObject that can find anIConnector. This registers a Topics tab on theConnectorHud, listing one row (VisualizationTopicsTabEntry) per topic the connector has seen. - Find the topic you want, using the topic name filter or by sorting the list by the 2D, 3D, or Topic columns.
- Enable 2D to open a HUD window that renders
IVisual.OnGUI, or enable 3D to callSetDrawingEnabledon the visual. The 3D toggle only appears when the resolved factory reportsCanShowDrawing.
The visualization now renders in the HUD, in the scene, or both. Unity saves the layout state (which topics to visualize, window positions) to RosHudLayout.json under Application.persistentDataPath, and is restored the next time you enter Play mode. To save or restore layout state at an explicit path instead, call SaveLayout(path) or LoadLayout(path).
Enable a visualization from code
To drive visualizations from code instead of clicking:
- Add an
ActivateVisualizationcomponent to a GameObject. - Set the serialized
TopicNamefield to the topic you want to visualize. - Enable
Enable2d,Enable3d, orFullscreen2dImageas needed.
ActivateVisualization applies these fields every frame, so toggling them from your own scripts turns the corresponding visualization on or off immediately.