docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class VuMeter

    A slim vertical audio level meter: a dB ruler, one or two thin level bars, an optional peak-hold line, and a draggable attenuation marker.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    VuMeter
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    Inherited Members
    VisualElement.disabledUssClassName
    VisualElement.SetActivePseudoState(bool)
    VisualElement.SetCheckedPseudoState(bool)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    VisualElement.IsMarkedForRepaint()
    VisualElement.ContainsPoint(Vector2)
    VisualElement.Overlaps(Rect)
    VisualElement.DoMeasure(float, VisualElement.MeasureMode, float, VisualElement.MeasureMode)
    VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(string)
    VisualElement.RemoveFromClassList(string)
    VisualElement.ToggleInClassList(string)
    VisualElement.EnableInClassList(string, bool)
    VisualElement.ClassListContains(string)
    VisualElement.FindAncestorUserData()
    VisualElement.SetBinding(BindingId, Binding)
    VisualElement.GetBinding(BindingId)
    VisualElement.TryGetBinding(BindingId, out Binding)
    VisualElement.GetBindingInfos()
    VisualElement.GetBindingInfos(List<BindingInfo>)
    VisualElement.HasBinding(BindingId)
    VisualElement.ClearBinding(BindingId)
    VisualElement.ClearBindings()
    VisualElement.GetHierarchicalDataSourceContext()
    VisualElement.GetDataSourceContext(BindingId)
    VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
    VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
    VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(int, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(int)
    VisualElement.Clear()
    VisualElement.ElementAt(int)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    VisualElement.Sort(Comparison<VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    VisualElement.GetFirstOfType<T>()
    VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    VisualElement.viewDataKey
    VisualElement.userData
    VisualElement.canGrabFocus
    VisualElement.focusController
    VisualElement.disablePlayModeTint
    VisualElement.usageHints
    VisualElement.transform
    VisualElement.scaledPixelsPerPoint
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.hasActivePseudoState
    VisualElement.hasInactivePseudoState
    VisualElement.hasHoverPseudoState
    VisualElement.hasCheckedPseudoState
    VisualElement.hasEnabledPseudoState
    VisualElement.hasDisabledPseudoState
    VisualElement.hasFocusPseudoState
    VisualElement.hasRootPseudoState
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.languageDirection
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.dataSource
    VisualElement.dataSourcePath
    VisualElement.dataSourceType
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.resolvedStyle
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
    CallbackEventHandler.UnregisterAllRemovableCallbacks()
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    CallbackEventHandler.HandleEventBubbleUp(EventBase)
    CallbackEventHandler.HandleEventTrickleDown(EventBase)
    CallbackEventHandler.ExecuteDefaultAction(EventBase)
    CallbackEventHandler.NotifyPropertyChanged(in BindingId)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    [UxmlElement]
    public class VuMeter : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler
    Remarks

    VuMeter mirrors the meter beside a channel strip in Unity's Audio Mixer. It is presentational: feed it live levels and it paints them. It never reads an AudioMixer itself, so it is equally usable for a microphone preview, a VOIP indicator or a test signal.

    The level colour is anchored to fader rather than to a fixed dB: safe well below the marker, warning as the level approaches it, clipping once it passes. Move the fader and the bands move with it, which is what makes the meter readable at any attenuation.

    Rendering.

    Each channel bar is stroked and filled into its own mesh with Painter2D, the same path CanvasEdge and AnimationCurveField take, because the fill is a banded gradient that USS cannot express. A shader would be overkill for a few filled rectangles; those are reserved for full-surface fills like ColorWheel's. The ruler, the marker chip and the readout are ordinary elements, styled from USS.

    Colours.

    Every colour the painter uses is read in C#, so none may be a literal. They come from custom style properties that VuMeter.uss binds to App UI tokens, and the C# fields start at clear so an unresolved stylesheet is visible rather than plausible.

    Example

    var meter = new VuMeter { levels = new List<float> { -12f, -18f }, fader = -6f };
    meter.faderChanged += db => mixer.SetFloat("Volume", db);

    UXML

    <appui:VuMeter min="-80" max="20" show-readout="true" />

    Constructors

    VuMeter()

    Default constructor.

    Declaration
    public VuMeter()

    Fields

    barUssClassName

    One channel bar.

    Declaration
    public const string barUssClassName = "appui-vu-meter__bar"
    Field Value
    Type Description
    string

    barsUssClassName

    The container the per-channel bars live in.

    Declaration
    public const string barsUssClassName = "appui-vu-meter__bars"
    Field Value
    Type Description
    string

    bodyUssClassName

    The row holding the meter group and the ruler.

    Declaration
    public const string bodyUssClassName = "appui-vu-meter__body"
    Field Value
    Type Description
    string

    defaultMax

    The default top of the scale, in dB.

    Declaration
    public const float defaultMax = 20
    Field Value
    Type Description
    float

    defaultMin

    The default bottom of the scale, in dB.

    Declaration
    public const float defaultMin = -80
    Field Value
    Type Description
    float

    dragLaneUssClassName

    The invisible lane that accepts the fader drag.

    Declaration
    public const string dragLaneUssClassName = "appui-vu-meter__drag-lane"
    Field Value
    Type Description
    string

    markerArrowUssClassName

    The marker's arrow head.

    Declaration
    public const string markerArrowUssClassName = "appui-vu-meter__marker-arrow"
    Field Value
    Type Description
    string

    markerLabelUssClassName

    The marker's numeric chip.

    Declaration
    public const string markerLabelUssClassName = "appui-vu-meter__marker-label"
    Field Value
    Type Description
    string

    markerUssClassName

    The attenuation marker.

    Declaration
    public const string markerUssClassName = "appui-vu-meter__marker"
    Field Value
    Type Description
    string

    meterUssClassName

    The meter group: bars, peak line and the attenuation marker.

    Declaration
    public const string meterUssClassName = "appui-vu-meter__meter"
    Field Value
    Type Description
    string

    noReadoutUssClassName

    The styling class applied when the numeric readout is hidden.

    Declaration
    public const string noReadoutUssClassName = "appui-vu-meter--no-readout"
    Field Value
    Type Description
    string

    readoutUssClassName

    The numeric level readout under the meter.

    Declaration
    public const string readoutUssClassName = "appui-vu-meter__readout"
    Field Value
    Type Description
    string

    rulerUssClassName

    The dB ruler.

    Declaration
    public const string rulerUssClassName = "appui-vu-meter__ruler"
    Field Value
    Type Description
    string

    tickDashUssClassName

    A ruler row's dash.

    Declaration
    public const string tickDashUssClassName = "appui-vu-meter__tick-dash"
    Field Value
    Type Description
    string

    tickLabelUssClassName

    A ruler row's label.

    Declaration
    public const string tickLabelUssClassName = "appui-vu-meter__tick-label"
    Field Value
    Type Description
    string

    tickUssClassName

    One ruler row: a dash plus its label.

    Declaration
    public const string tickUssClassName = "appui-vu-meter__tick"
    Field Value
    Type Description
    string

    ussClassName

    The VuMeter main styling class.

    Declaration
    public const string ussClassName = "appui-vu-meter"
    Field Value
    Type Description
    string

    warningRange

    How far below the fader the warning band starts, in dB.

    Declaration
    public const float warningRange = 12
    Field Value
    Type Description
    float

    Properties

    barCount

    The number of channel bars currently painted.

    Declaration
    public int barCount { get; }
    Property Value
    Type Description
    int

    barsElement

    The container the channel bars live in.

    Declaration
    public VisualElement barsElement { get; }
    Property Value
    Type Description
    VisualElement

    contentContainer

    Logical container where child elements are added. If a child is added to this element, the child is added to this element's content container instead.

    Declaration
    public override VisualElement contentContainer { get; }
    Property Value
    Type Description
    VisualElement
    Overrides
    VisualElement.contentContainer

    fader

    The attenuation fader, in dB. Always inside min..max, and the anchor the level colour bands are measured from.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public float fader { get; set; }
    Property Value
    Type Description
    float

    levels

    The per-channel levels, in dB. One bar each; an empty list still paints a single silent bar.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public List<float> levels { get; set; }
    Property Value
    Type Description
    List<float>

    markerElement

    The attenuation marker.

    Declaration
    public VisualElement markerElement { get; }
    Property Value
    Type Description
    VisualElement

    max

    The top of the scale, in dB.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public float max { get; set; }
    Property Value
    Type Description
    float

    min

    The bottom of the scale, in dB.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public float min { get; set; }
    Property Value
    Type Description
    float

    peak

    The peak-hold marker, in dB. Unset hides it.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public Optional<float> peak { get; set; }
    Property Value
    Type Description
    Optional<float>

    readoutElement

    The numeric level readout.

    Declaration
    public LocalizedTextElement readoutElement { get; }
    Property Value
    Type Description
    LocalizedTextElement

    resolvedClipColor

    The clipping colour resolved from --vu-meter-clip-color.

    Declaration
    public Color resolvedClipColor { get; }
    Property Value
    Type Description
    Color

    resolvedFaderColor

    The fader marker colour resolved from --vu-meter-fader-color.

    Declaration
    public Color resolvedFaderColor { get; }
    Property Value
    Type Description
    Color

    resolvedPeakColor

    The peak-hold colour resolved from --vu-meter-peak-color.

    Declaration
    public Color resolvedPeakColor { get; }
    Property Value
    Type Description
    Color

    resolvedSafeColor

    The safe-level colour resolved from --vu-meter-safe-color.

    Declaration
    public Color resolvedSafeColor { get; }
    Property Value
    Type Description
    Color

    resolvedTrackColor

    The empty-track colour resolved from --vu-meter-track-color.

    Declaration
    public Color resolvedTrackColor { get; }
    Property Value
    Type Description
    Color

    resolvedWarningColor

    The approaching-clip colour resolved from --vu-meter-warning-color.

    Declaration
    public Color resolvedWarningColor { get; }
    Property Value
    Type Description
    Color

    rulerElement

    The dB ruler.

    Declaration
    public VisualElement rulerElement { get; }
    Property Value
    Type Description
    VisualElement

    showReadout

    Whether the numeric level readout shows under the meter.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public bool showReadout { get; set; }
    Property Value
    Type Description
    bool

    ticks

    The dB values the ruler marks. Rebuilt in full whenever it is assigned.

    Declaration
    [CreateProperty]
    [UxmlAttribute]
    public List<float> ticks { get; set; }
    Property Value
    Type Description
    List<float>

    Events

    faderChanged

    Raised whenever the fader lands on a new value, whether set in code or dragged.

    Declaration
    public event Action<float> faderChanged
    Event Type
    Type Description
    Action<float>

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    RegisterUpdateCallbackExtensions.RegisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    RegisterUpdateCallbackExtensions.UnregisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    VisualElementExtensions.EnableDynamicTransform(VisualElement, bool)
    VisualElementExtensions.EnablePicking(VisualElement, bool)
    VisualElementExtensions.GetChildren<T>(VisualElement, bool)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement, string)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement, string)
    VisualElementExtensions.GetExclusiveRootElement(VisualElement)
    VisualElementExtensions.GetLastAncestorOfType<T>(VisualElement)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement, string)
    VisualElementExtensions.GetTooltipContent(VisualElement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.HasAncestorOfType<T>(VisualElement, bool)
    VisualElementExtensions.HasAncestorsOfType<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement, string)
    VisualElementExtensions.IsInvisible(VisualElement)
    VisualElementExtensions.IsOnScreen(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, string, T)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, OptionalEnum<PopoverPlacement>)
    VisualElementExtensions.SetTooltipContent(VisualElement, VisualElementExtensions.TooltipContentCallback)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    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)