docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class VisualizationUtils

    Static utility methods and extension methods used across visualizer implementations for color selection, drawing, GUI layout, and TF tracking.

    Inheritance
    object
    VisualizationUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.SimulationPro.Foundation.Visualizations
    Assembly: Unity.SimulationPro.Foundation.Visualizations.dll
    Syntax
    public static class VisualizationUtils

    Methods

    AssertMessageType<T>(IMessage, string)

    Logs an error and returns false if message is not of type T.

    Declaration
    public static bool AssertMessageType<T>(IMessage message, string topic)
    Parameters
    Type Name Description
    IMessage message

    The message to check.

    string topic

    The topic name, used in the error message.

    Returns
    Type Description
    bool

    true if the message is of the expected type; false otherwise.

    Type Parameters
    Name Description
    T

    The expected message type.

    CreateDefaultGUI(IMessage, MessageMetadata)

    Returns a GUI action that displays the string representation of message.

    Declaration
    public static Action CreateDefaultGUI(IMessage message, MessageMetadata meta)
    Parameters
    Type Name Description
    IMessage message

    The ROS message to display.

    MessageMetadata meta

    Contextual metadata (unused in the default implementation).

    Returns
    Type Description
    Action

    A GUI rendering action.

    DrawAngularVelocityArrow(Drawing3d, Vector3, Vector3, Color32, float, float)

    Draws a circular arrow representing an angular velocity vector on a sphere surface.

    Declaration
    public static void DrawAngularVelocityArrow(Drawing3d drawing, Vector3 angularVelocity, Vector3 sphereCenter, Color32 color, float sphereRadius = 1, float arrowThickness = 0.01)
    Parameters
    Type Name Description
    Drawing3d drawing

    The drawing canvas.

    Vector3 angularVelocity

    The angular velocity vector; its magnitude determines the arc angle in radians.

    Vector3 sphereCenter

    The center position of the sphere.

    Color32 color

    The arrow color.

    float sphereRadius

    The radius of the reference sphere the arrow is drawn on.

    float arrowThickness

    The thickness of the arrow line.

    DrawAxisVectors<C>(Drawing3d, Vector3Msg, QuaternionMsg, float, bool)

    Draws three colored axis lines (X=red, Y=green, Z=blue) at the given position and orientation, in either ROS or Unity axis convention.

    Declaration
    public static void DrawAxisVectors<C>(Drawing3d drawing, Vector3Msg position, QuaternionMsg rotation, float size, bool drawUnityAxes) where C : ICoordinateSpace, new()
    Parameters
    Type Name Description
    Drawing3d drawing

    The drawing canvas.

    Vector3Msg position

    The origin position in the specified coordinate space.

    QuaternionMsg rotation

    The orientation in the specified coordinate space.

    float size

    The length of each axis line.

    bool drawUnityAxes

    If true, uses Unity's X/Y/Z axes; if false, uses the coordinate-space axes.

    Type Parameters
    Name Description
    C

    The coordinate space type used to convert the ROS position and rotation.

    DrawPointCloud<C>(Point32Msg[], Drawing3d, Color, float)

    Draws an array of Point32Msg values as a point cloud using the specified color and radius.

    Declaration
    public static void DrawPointCloud<C>(Point32Msg[] points, Drawing3d drawing, Color color, float radius = 0.01) where C : ICoordinateSpace, new()
    Parameters
    Type Name Description
    Point32Msg[] points

    The array of ROS point messages.

    Drawing3d drawing

    The drawing canvas.

    Color color

    The point color.

    float radius

    The radius of each rendered point.

    Type Parameters
    Name Description
    C

    The coordinate space type used to convert points.

    DrawPointCloud<C>(PointMsg[], Drawing3d, Color, float)

    Draws an array of PointMsg values as a point cloud using the specified color and radius.

    Declaration
    public static void DrawPointCloud<C>(PointMsg[] points, Drawing3d drawing, Color color, float radius = 0.01) where C : ICoordinateSpace, new()
    Parameters
    Type Name Description
    PointMsg[] points

    The array of ROS point messages.

    Drawing3d drawing

    The drawing canvas.

    Color color

    The point color.

    float radius

    The radius of each rendered point.

    Type Parameters
    Name Description
    C

    The coordinate space type used to convert points.

    DrawRotationArrow(Drawing3d, Quaternion, Vector3, Color32, float, float)

    Draws a circular arrow representing a rotation quaternion on a sphere surface.

    Declaration
    public static void DrawRotationArrow(Drawing3d drawing, Quaternion rotation, Vector3 sphereCenter, Color32 color, float sphereRadius = 1, float arrowThickness = 0.01)
    Parameters
    Type Name Description
    Drawing3d drawing

    The drawing canvas.

    Quaternion rotation

    The rotation to visualize; decomposed into axis and angle.

    Vector3 sphereCenter

    The center position of the sphere.

    Color32 color

    The arrow color.

    float sphereRadius

    The radius of the reference sphere the arrow is drawn on.

    float arrowThickness

    The thickness of the arrow line.

    DrawRotationArrow(Drawing3d, Vector3, float, Vector3, Color32, float, float)

    Draws a circular arrow arc on a sphere surface representing a rotation about the given axis.

    Declaration
    public static void DrawRotationArrow(Drawing3d drawing, Vector3 rotationAxis, float rotationDegrees, Vector3 sphereCenter, Color32 color, float sphereRadius = 1, float arrowThickness = 0.01)
    Parameters
    Type Name Description
    Drawing3d drawing

    The drawing canvas.

    Vector3 rotationAxis

    The axis of rotation (should be normalized).

    float rotationDegrees

    The rotation angle in degrees; determines the arc length.

    Vector3 sphereCenter

    The center position of the sphere.

    Color32 color

    The arrow color.

    float sphereRadius

    The radius of the reference sphere the arrow is drawn on.

    float arrowThickness

    The thickness of the arrow line.

    DrawingSetTFTracking(Drawing3d, TFTrackingSettings, HeaderMsg, Transform)

    Positions and orients a Drawing3d according to the TF tracking mode specified in tfTrackingType.

    Declaration
    public static void DrawingSetTFTracking(Drawing3d drawing, TFTrackingSettings tfTrackingType, HeaderMsg headerMsg, Transform visualizerTransform)
    Parameters
    Type Name Description
    Drawing3d drawing

    The drawing to reposition.

    TFTrackingSettings tfTrackingType

    The tracking settings that control which TF frame the drawing follows.

    HeaderMsg headerMsg

    The ROS header providing the frame ID and timestamp.

    Transform visualizerTransform

    The visualizer's own transform, used when mode is RelativeToVisualizer.

    GUI(TimeMsg)

    Renders a 2D GUI label displaying the timestamp represented by a TimeMsg.

    Declaration
    public static void GUI(this TimeMsg message)
    Parameters
    Type Name Description
    TimeMsg message

    The time message to display.

    GUI(SelfTestResponse)

    Renders a 2D GUI label showing the pass/fail result of a SelfTestResponse and each diagnostic status entry.

    Declaration
    public static void GUI(this SelfTestResponse message)
    Parameters
    Type Name Description
    SelfTestResponse message

    The self-test response to display.

    GUI(AccelMsg)

    Renders a 2D GUI label displaying the linear and angular components of an AccelMsg.

    Declaration
    public static void GUI(this AccelMsg message)
    Parameters
    Type Name Description
    AccelMsg message

    The acceleration message to display.

    GUI(InertiaMsg)

    Renders a 2D GUI label displaying the mass, center of mass, and inertia tensor components of an InertiaMsg.

    Declaration
    public static void GUI(this InertiaMsg message)
    Parameters
    Type Name Description
    InertiaMsg message

    The inertia message to display.

    GUI(Point32Msg)

    Renders a 2D GUI label displaying the XYZ coordinates of a Point32Msg.

    Declaration
    public static void GUI(this Point32Msg message)
    Parameters
    Type Name Description
    Point32Msg message

    The point message to display.

    GUI(Point32Msg, string)

    Renders a 2D GUI label displaying the XYZ coordinates of a Point32Msg with an optional prefix name.

    Declaration
    public static void GUI(this Point32Msg message, string name)
    Parameters
    Type Name Description
    Point32Msg message

    The point message to display.

    string name

    An optional label prefix; if empty or null, only the coordinates are shown.

    GUI(PointMsg)

    Renders a 2D GUI label displaying the XYZ coordinates of a PointMsg.

    Declaration
    public static void GUI(this PointMsg message)
    Parameters
    Type Name Description
    PointMsg message

    The point message to display.

    GUI(PointMsg, string)

    Renders a 2D GUI label displaying the XYZ coordinates of a PointMsg with an optional prefix name.

    Declaration
    public static void GUI(this PointMsg message, string name)
    Parameters
    Type Name Description
    PointMsg message

    The point message to display.

    string name

    An optional label prefix; if empty or null, only the coordinates are shown.

    GUI(PolygonMsg)

    Renders a 2D GUI label listing the point count and each vertex of a PolygonMsg.

    Declaration
    public static void GUI(this PolygonMsg message)
    Parameters
    Type Name Description
    PolygonMsg message

    The polygon message to display.

    GUI(PoseArrayMsg)

    Renders a 2D GUI label displaying the header and all pose entries of a PoseArrayMsg.

    Declaration
    public static void GUI(this PoseArrayMsg message)
    Parameters
    Type Name Description
    PoseArrayMsg message

    The pose array message to display.

    GUI(PoseMsg, string)

    Renders a 2D GUI label displaying the position and orientation of a PoseMsg, with an optional header name.

    Declaration
    public static void GUI(this PoseMsg message, string name = "")
    Parameters
    Type Name Description
    PoseMsg message

    The pose message to display.

    string name

    An optional header label rendered above the pose components; omitted when empty.

    GUI(QuaternionMsg)

    Renders a 2D GUI label displaying the XYZW components of a QuaternionMsg.

    Declaration
    public static void GUI(this QuaternionMsg message)
    Parameters
    Type Name Description
    QuaternionMsg message

    The quaternion message to display.

    GUI(QuaternionMsg, string)

    Renders a 2D GUI label displaying the XYZW components of a QuaternionMsg with an optional prefix label.

    Declaration
    public static void GUI(this QuaternionMsg message, string label)
    Parameters
    Type Name Description
    QuaternionMsg message

    The quaternion message to display.

    string label

    A prefix string prepended to the component values; ignored when empty or null.

    GUI(TransformMsg)

    Renders a 2D GUI label displaying the translation and rotation of a TransformMsg.

    Declaration
    public static void GUI(this TransformMsg message)
    Parameters
    Type Name Description
    TransformMsg message

    The transform message to display.

    GUI(TwistMsg, string)

    Renders a 2D GUI label displaying the linear and angular components of a TwistMsg, with an optional header name.

    Declaration
    public static void GUI(this TwistMsg message, string name = "")
    Parameters
    Type Name Description
    TwistMsg message

    The twist message to display.

    string name

    An optional header label rendered above the components; omitted when empty.

    GUI(Vector3Msg)

    Renders a 2D GUI label displaying the XYZ components of a Vector3Msg.

    Declaration
    public static void GUI(this Vector3Msg message)
    Parameters
    Type Name Description
    Vector3Msg message

    The vector message to display.

    GUI(Vector3Msg, string)

    Renders a 2D GUI label displaying the XYZ components of a Vector3Msg with an optional prefix name.

    Declaration
    public static void GUI(this Vector3Msg message, string name)
    Parameters
    Type Name Description
    Vector3Msg message

    The vector message to display.

    string name

    An optional label prefix; if empty or null, only the coordinates are shown.

    GUI(WrenchMsg)

    Renders a 2D GUI label displaying the force and torque components of a WrenchMsg.

    Declaration
    public static void GUI(this WrenchMsg message)
    Parameters
    Type Name Description
    WrenchMsg message

    The wrench message to display.

    GUI(MapMetaDataMsg)

    Renders a 2D GUI label displaying the map load time, resolution, dimensions, and origin of a MapMetaDataMsg.

    Declaration
    public static void GUI(this MapMetaDataMsg message)
    Parameters
    Type Name Description
    MapMetaDataMsg message

    The map metadata message to display.

    GUI(JoyFeedbackMsg)

    Renders a 2D GUI label displaying the type, ID, and intensity of a JoyFeedbackMsg.

    Declaration
    public static void GUI(this JoyFeedbackMsg message)
    Parameters
    Type Name Description
    JoyFeedbackMsg message

    The joystick feedback message to display.

    GUI(NavSatStatusMsg)

    Renders a 2D GUI label displaying the status and service type of a NavSatStatusMsg.

    Declaration
    public static void GUI(this NavSatStatusMsg message)
    Parameters
    Type Name Description
    NavSatStatusMsg message

    The navigation satellite status message to display.

    GUI(PointFieldMsg)

    Renders a 2D GUI label displaying the name, data type, and optional count of a PointFieldMsg.

    Declaration
    public static void GUI(this PointFieldMsg message)
    Parameters
    Type Name Description
    PointFieldMsg message

    The point field message to display.

    GUI(RegionOfInterestMsg, Texture2D)

    Renders a 2D GUI label displaying the offset, size, and rectification flag of a RegionOfInterestMsg. Optionally renders a cropped texture.

    Declaration
    public static void GUI(this RegionOfInterestMsg message, Texture2D tex = null)
    Parameters
    Type Name Description
    RegionOfInterestMsg message

    The region-of-interest message to display.

    Texture2D tex

    An optional texture to render above the label; skipped when null.

    GUI(MeshMsg)

    Renders a 2D GUI label for each vertex and triangle in a MeshMsg.

    Declaration
    public static void GUI(this MeshMsg message)
    Parameters
    Type Name Description
    MeshMsg message

    The mesh message to display.

    GUI(MeshTriangleMsg)

    Renders a 2D GUI label showing the vertex indices of a MeshTriangleMsg.

    Declaration
    public static void GUI(this MeshTriangleMsg message)
    Parameters
    Type Name Description
    MeshTriangleMsg message

    The mesh triangle message to display.

    GUI(SolidPrimitiveMsg)

    Renders a 2D GUI label describing the type and dimensions of a SolidPrimitiveMsg (box, sphere, cylinder, or cone).

    Declaration
    public static void GUI(this SolidPrimitiveMsg message)
    Parameters
    Type Name Description
    SolidPrimitiveMsg message

    The solid primitive message to display.

    GUI(ColorRGBAMsg, bool)

    Renders a color swatch and optional RGBA text label for a ColorRGBAMsg.

    Declaration
    public static void GUI(this ColorRGBAMsg message, bool withText = true)
    Parameters
    Type Name Description
    ColorRGBAMsg message

    The color message to display.

    bool withText

    If true, also renders an RGBA text label alongside the swatch.

    GUI(HeaderMsg)

    Renders a collapsible header label showing the frame ID and timestamp from a HeaderMsg.

    Declaration
    public static void GUI(this HeaderMsg message)
    Parameters
    Type Name Description
    HeaderMsg message

    The header message to display.

    GUIGrid<T>(T[], int, ref bool)

    Renders a toggle-controlled grid layout of data values with width columns.

    Declaration
    public static void GUIGrid<T>(T[] data, int width, ref bool view)
    Parameters
    Type Name Description
    T[] data

    The flat data array to display.

    int width

    The number of columns in the grid.

    bool view

    Whether the grid is currently expanded; toggled by a button.

    Type Parameters
    Name Description
    T

    The element type.

    GUIGrid<T>(T[], int, string, ref bool)

    Renders a toggle-controlled named grid layout of data values with width columns.

    Declaration
    public static void GUIGrid<T>(T[] data, int width, string name, ref bool view)
    Parameters
    Type Name Description
    T[] data

    The flat data array to display.

    int width

    The number of columns in the grid.

    string name

    The display name shown in the toggle label.

    bool view

    Whether the grid is currently expanded; toggled by a button.

    Type Parameters
    Name Description
    T

    The element type.

    GUIMultiArray<T>(MultiArrayLayoutMsg, T[], bool)

    Renders a MultiArrayLayoutMsg-shaped data array using the specified layout mode.

    Declaration
    public static void GUIMultiArray<T>(this MultiArrayLayoutMsg layout, T[] data, bool tabulate = true)
    Parameters
    Type Name Description
    MultiArrayLayoutMsg layout

    The multi-array layout describing the dimensions of data.

    T[] data

    The flat data array.

    bool tabulate

    If true, renders rows horizontally; if false, renders elements vertically.

    Type Parameters
    Name Description
    T

    The element type.

    GUIMultiArray<T>(MultiArrayLayoutMsg, T[], ref bool)

    Renders a MultiArrayLayoutMsg-shaped data array with a toggle for switching between table and vertical list layout.

    Declaration
    public static void GUIMultiArray<T>(this MultiArrayLayoutMsg layout, T[] data, ref bool tabulate)
    Parameters
    Type Name Description
    MultiArrayLayoutMsg layout

    The multi-array layout describing the dimensions of data.

    T[] data

    The flat data array.

    bool tabulate

    Whether to use table layout; toggled by a button.

    Type Parameters
    Name Description
    T

    The element type.

    GUITexture(Texture2D)

    Renders a Texture2D in the GUI maintaining its original aspect ratio. Does nothing if tex is null.

    Declaration
    public static void GUITexture(this Texture2D tex)
    Parameters
    Type Name Description
    Texture2D tex

    The texture to render.

    GUITexture(Texture2D, Material)

    Renders a Texture2D in the GUI using a custom material, maintaining the original aspect ratio. Does nothing if tex is null.

    Declaration
    public static void GUITexture(this Texture2D tex, Material material)
    Parameters
    Type Name Description
    Texture2D tex

    The texture to render.

    Material material

    The material to use during rendering.

    GetVisual(IConnector, string, MessageDisambiguator)

    Returns an IVisual for the given topic by looking up the best factory from VisualFactoryRegistry. Returns null if no factory is available.

    Declaration
    public static IVisual GetVisual(IConnector connector, string topic, MessageDisambiguator disambiguator = MessageDisambiguator.Default)
    Parameters
    Type Name Description
    IConnector connector

    The connector to use.

    string topic

    The ROS topic name.

    MessageDisambiguator disambiguator

    Disambiguator for service request/response topics.

    Returns
    Type Description
    IVisual

    The visual instance, or null.

    GetVisual(IConnector, string, MessageTypeId)

    Returns an IVisual for the given topic and message type ID by looking up the best factory from VisualFactoryRegistry. Returns null if no factory is available.

    Declaration
    public static IVisual GetVisual(IConnector connector, string topic, MessageTypeId messageTypeId)
    Parameters
    Type Name Description
    IConnector connector

    The connector to use.

    string topic

    The ROS topic name.

    MessageTypeId messageTypeId

    The message type ID.

    Returns
    Type Description
    IVisual

    The visual instance, or null.

    MakeTexture(int, int, Color)

    Creates a solid-color Texture2D of the given dimensions.

    Declaration
    public static Texture2D MakeTexture(int width, int height, Color color)
    Parameters
    Type Name Description
    int width

    The texture width in pixels.

    int height

    The texture height in pixels.

    Color color

    The fill color.

    Returns
    Type Description
    Texture2D

    A new Texture2D filled with color.

    PickColorForTopic(string)

    Derives a deterministic Color32 from the topic name's hash code. Returns black for an empty topic.

    Declaration
    public static Color32 PickColorForTopic(string topic)
    Parameters
    Type Name Description
    string topic

    The ROS topic name.

    Returns
    Type Description
    Color32

    A color derived from the topic name.

    SelectColor(Color, MessageMetadata)

    Returns userColor if non-zero and non-transparent; otherwise derives a color from the topic name in meta.

    Declaration
    public static Color SelectColor(Color userColor, MessageMetadata meta)
    Parameters
    Type Name Description
    Color userColor

    The user-configured color.

    MessageMetadata meta

    Metadata providing the topic name for automatic color selection.

    Returns
    Type Description
    Color

    The resolved color.

    SelectLabel(string, MessageMetadata)

    Returns userLabel if non-empty; otherwise returns the topic name from meta.

    Declaration
    public static string SelectLabel(string userLabel, MessageMetadata meta)
    Parameters
    Type Name Description
    string userLabel

    The user-configured label.

    MessageMetadata meta

    Metadata providing the topic name as the fallback label.

    Returns
    Type Description
    string

    The resolved label string.

    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)