docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class FloatingWindow

    A draggable, resizable window that floats above the rest of the UI and remembers where the user left it.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BaseVisualElement
    FloatingWindow
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    Inherited Members
    BaseVisualElement.contextPrefix
    BaseVisualElement.densityOverride
    BaseVisualElement.themeOverride
    BaseVisualElement.langOverride
    BaseVisualElement.layoutDirectionOverride
    BaseVisualElement.preferredTooltipPlacementOverride
    BaseVisualElement.tooltipDelayMsOverride
    BaseVisualElement.GetLayoutDirectionUssClassName(Dir)
    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 FloatingWindow : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
    Remarks

    The window positions itself absolutely inside its parent, so give it a parent that fills the area you want it to roam. Its title bar is the drag handle and its bottom-right corner carries a ResizeHandle; both clamp the result so the whole window stays inside the parent rather than leaving a sliver on screen.

    Geometry is persisted under storageKey through storage, which defaults to PlayerPrefsWindowLayoutStorage — the platform-native counterpart of the registry's window.localStorage default. Restoring re-clamps against the current container, so a layout saved on a larger screen still comes back fully visible.

    autoSize lets the content size the window and implies it is not resizable, matching the registry.

    Not ported: the registry's Tab focus trap and its shared window stack (useWindowStack) have no UI Toolkit counterpart here. Ordering between several floating windows is whatever their order in the hierarchy gives you; bring one forward by re-adding it to its parent.

    Examples

    A tool window in UXML.

    <appui:FloatingWindow title="Inspector" storage-key="inspector-window" open="true">
        <appui:Text text="Anything you like goes here." />
    </appui:FloatingWindow>

    Opened from C#, with an injected store.

    var window = new FloatingWindow
    {
        title = "Inspector",
        storageKey = "inspector-window",
        storage = myPreferencesAdapter,
        defaultWidth = 360f,
        defaultHeight = 480f,
    };
    window.Add(new Text { text = "Anything you like goes here." });
    window.openChanged += isOpen => Debug.Log($"open: {isOpen}");
    root.Add(window);
    window.open = true;

    Constructors

    FloatingWindow()

    Default constructor.

    Declaration
    public FloatingWindow()

    Fields

    autoSizeUssClassName

    The styling class applied while autoSize is on.

    Declaration
    public const string autoSizeUssClassName = "appui-floating-window--auto-size"
    Field Value
    Type Description
    string

    bodyUssClassName

    The styling class of the body the content lives in.

    Declaration
    public const string bodyUssClassName = "appui-floating-window__body"
    Field Value
    Type Description
    string

    closeButtonUssClassName

    The styling class of the close button.

    Declaration
    public const string closeButtonUssClassName = "appui-floating-window__close-button"
    Field Value
    Type Description
    string

    defaultMargin

    The margin kept between a defaulted window and the container's bottom-right corner.

    Declaration
    public const float defaultMargin = 24
    Field Value
    Type Description
    float

    defaultMinHeight

    The default minimum window height, in pixels. Mirrors the registry.

    Declaration
    public const float defaultMinHeight = 240
    Field Value
    Type Description
    float

    defaultMinWidth

    The default minimum window width, in pixels. Mirrors the registry.

    Declaration
    public const float defaultMinWidth = 320
    Field Value
    Type Description
    float

    defaultWindowHeight

    The default window height, in pixels. Mirrors the registry.

    Declaration
    public const float defaultWindowHeight = 600
    Field Value
    Type Description
    float

    defaultWindowWidth

    The default window width, in pixels. Mirrors the registry.

    Declaration
    public const float defaultWindowWidth = 420
    Field Value
    Type Description
    float

    headerUssClassName

    The styling class of the title bar, which is also the drag handle.

    Declaration
    public const string headerUssClassName = "appui-floating-window__header"
    Field Value
    Type Description
    string

    resizeHandleUssClassName

    The styling class of the bottom-right resize grip.

    Declaration
    public const string resizeHandleUssClassName = "appui-floating-window__resize-handle"
    Field Value
    Type Description
    string

    titleUssClassName

    The styling class of the title text.

    Declaration
    public const string titleUssClassName = "appui-floating-window__title"
    Field Value
    Type Description
    string

    ussClassName

    The FloatingWindow main styling class.

    Declaration
    public const string ussClassName = "appui-floating-window"
    Field Value
    Type Description
    string

    Properties

    autoSize

    Whether the window sizes itself to its content instead of to a fixed box.

    Declaration
    [Tooltip("Whether the window sizes itself to its content.")]
    [CreateProperty]
    [UxmlAttribute]
    public bool autoSize { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    This implies not resizable, and neither the width nor the height is persisted while it is on.

    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

    defaultHeight

    The height the window opens at when nothing has been persisted, in pixels.

    Declaration
    [Tooltip("The height the window opens at when nothing has been persisted.")]
    [CreateProperty]
    [UxmlAttribute]
    public float defaultHeight { get; set; }
    Property Value
    Type Description
    float

    defaultWidth

    The width the window opens at when nothing has been persisted, in pixels.

    Declaration
    [Tooltip("The width the window opens at when nothing has been persisted.")]
    [CreateProperty]
    [UxmlAttribute]
    public float defaultWidth { get; set; }
    Property Value
    Type Description
    float

    defaultX

    The x the window opens at when nothing has been persisted. NaN (the default) places it against the container's right edge.

    Declaration
    public float defaultX { get; set; }
    Property Value
    Type Description
    float

    defaultY

    The y the window opens at when nothing has been persisted. NaN (the default) places it against the container's bottom edge.

    Declaration
    public float defaultY { get; set; }
    Property Value
    Type Description
    float

    dismissable

    Whether the title bar shows a close button.

    Declaration
    [Tooltip("Whether the title bar shows a close button.")]
    [CreateProperty]
    [UxmlAttribute]
    public bool dismissable { get; set; }
    Property Value
    Type Description
    bool

    layoutGeometry

    The geometry the window is currently at, in pixels relative to its parent.

    Declaration
    public WindowLayout layoutGeometry { get; }
    Property Value
    Type Description
    WindowLayout

    layoutResolved

    Whether the window has resolved a geometry yet, either restored or defaulted.

    Declaration
    public bool layoutResolved { get; }
    Property Value
    Type Description
    bool

    minHeight

    The smallest height the resize grip will produce, in pixels.

    Declaration
    [Tooltip("The smallest height the resize grip will produce.")]
    [CreateProperty]
    [UxmlAttribute]
    public float minHeight { get; set; }
    Property Value
    Type Description
    float

    minWidth

    The smallest width the resize grip will produce, in pixels.

    Declaration
    [Tooltip("The smallest width the resize grip will produce.")]
    [CreateProperty]
    [UxmlAttribute]
    public float minWidth { get; set; }
    Property Value
    Type Description
    float

    open

    Whether the window is currently shown.

    Declaration
    [Tooltip("Whether the window is currently shown.")]
    [CreateProperty]
    [UxmlAttribute]
    public bool open { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    Opening restores the persisted geometry, or falls back to the defaults when there is none. Closing only hides the window; the geometry stays saved.

    resizable

    Whether the bottom-right resize grip is shown. Ignored while autoSize is on.

    Declaration
    [Tooltip("Whether the bottom-right resize grip is shown.")]
    [CreateProperty]
    [UxmlAttribute]
    public bool resizable { get; set; }
    Property Value
    Type Description
    bool

    storage

    The persistence backend. Defaults to instance.

    Declaration
    public IWindowLayoutStorage storage { get; set; }
    Property Value
    Type Description
    IWindowLayoutStorage
    Remarks

    Set this to null to fall back to the default. Set it to an in-memory implementation in tests, or to your own adapter to route the layout into an existing preference store.

    storageKey

    The key the geometry is persisted under.

    Declaration
    [Tooltip("The key the window geometry is persisted under.")]
    [CreateProperty]
    [UxmlAttribute]
    public string storageKey { get; set; }
    Property Value
    Type Description
    string
    Remarks

    Give every window in your app its own key, or two windows will fight over one saved layout.

    title

    The window's title. Accepts a localization key.

    Declaration
    [Tooltip("The window's title.")]
    [CreateProperty]
    [UxmlAttribute]
    public string title { get; set; }
    Property Value
    Type Description
    string

    Methods

    ResetLayout()

    Forgets the persisted geometry and returns the window to its defaults.

    Declaration
    public void ResetLayout()

    RestoreLayout()

    Restores the persisted geometry, falling back to the defaults when there is none.

    Declaration
    public void RestoreLayout()
    Remarks

    The restored geometry is re-clamped against the current container size and the current minWidth / minHeight, so a layout saved on a larger screen comes back fully visible rather than off-screen.

    SaveLayout()

    Writes the current geometry to storage under storageKey.

    Declaration
    public void SaveLayout()
    Remarks

    This runs automatically at the end of a drag or a resize. Call it directly only if you move the window by setting its style yourself.

    Events

    openChanged

    Raised when open changes.

    Declaration
    public event Action<bool> openChanged
    Event Type
    Type Description
    Action<bool>

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder

    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)