docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Popup

    This is the base class for any UI component that needs to be displayed over the rest of the user interface.

    Inheritance
    object
    Popup
    Popup<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    public abstract class Popup

    Constructors

    Popup(VisualElement, VisualElement, VisualElement)

    Default constructor.

    Declaration
    protected Popup(VisualElement parentView, VisualElement view, VisualElement contentView = null)
    Parameters
    Type Name Description
    VisualElement parentView

    The popup container.

    VisualElement view

    The popup visual element itself.

    VisualElement contentView

    The content that will appear inside this popup.

    Exceptions
    Type Condition
    ArgumentException

    The container can't be null.

    Fields

    k_NextFrameDurationMs

    The average duration of a frame in milliseconds. Used to delay position calculations.

    Declaration
    protected const int k_NextFrameDurationMs = 16
    Field Value
    Type Description
    int

    k_PopupDismiss

    The message id used to dismiss the popup.

    Declaration
    protected const int k_PopupDismiss = 2
    Field Value
    Type Description
    int

    k_PopupShow

    The message id used to show the popup.

    Declaration
    protected const int k_PopupShow = 1
    Field Value
    Type Description
    int

    Properties

    contentView

    The content of the popup.

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

    handler

    The handler that receives and dispatches messages. This is useful in multi-threaded applications.

    Declaration
    protected Handler handler { get; }
    Property Value
    Type Description
    Handler

    keyboardDismissEnabled

    True if the the popup can be dismissed by pressing the escape key or the return button on mobile, False otherwise.

    The default value is `True`.

    Declaration
    public bool keyboardDismissEnabled { get; protected set; }
    Property Value
    Type Description
    bool

    targetParent

    The parent of the view when the popup will be displayed.

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

    view

    Returns the popup's VisualElement.

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

    Methods

    AnimateViewIn()

    Start the animation for this popup.

    Declaration
    protected virtual void AnimateViewIn()

    AnimateViewOut(DismissType)

    Start the hide animation for this popup.

    Declaration
    protected virtual void AnimateViewOut(DismissType reason)
    Parameters
    Type Name Description
    DismissType reason

    The reason why the popup should be dismissed.

    Dismiss()

    Dismiss the Popup.

    Declaration
    public virtual void Dismiss()

    Dismiss(DismissType)

    Dismiss the Popup.

    Declaration
    public virtual void Dismiss(DismissType reason)
    Parameters
    Type Name Description
    DismissType reason

    Why the element has been dismissed.

    FindSuitableParent(VisualElement)

    Find the parent VisualElement where the popup will be added. This is usually one of the layers from the Panel root UI element.

    Declaration
    protected virtual VisualElement FindSuitableParent(VisualElement element)
    Parameters
    Type Name Description
    VisualElement element

    An arbitrary UI element inside the panel.

    Returns
    Type Description
    VisualElement

    The popup container VisualElement in the current panel.

    GetFocusableElement()

    Returns the element that will be focused when the view will become visible.

    The default value is `null`.

    Declaration
    protected virtual VisualElement GetFocusableElement()
    Returns
    Type Description
    VisualElement

    The element that will be focused when the view will become visible.

    HideView(DismissType)

    Called when the popup's Handler has received a k_PopupDismiss message.

    Declaration
    protected virtual void HideView(DismissType reason)
    Parameters
    Type Name Description
    DismissType reason

    The reason why the popup should be dismissed.

    InvokeDismissedEventHandlers(DismissType)

    Called when the popup has completed its dismiss process.

    Declaration
    protected virtual void InvokeDismissedEventHandlers(DismissType reason)
    Parameters
    Type Name Description
    DismissType reason

    The reason why the popup has been dismissed.

    InvokeShownEventHandlers()

    Called when the popup has become visible.

    Declaration
    protected virtual void InvokeShownEventHandlers()

    OnViewKeyDown(KeyDownEvent)

    Called when the popup has received a KeyDownEvent.

    By default this method handles the dismiss of the popup via the Escape key or a Return button.

    Declaration
    protected virtual void OnViewKeyDown(KeyDownEvent evt)
    Parameters
    Type Name Description
    KeyDownEvent evt

    The event the popup has received.

    ShouldAnimate()

    Implement this method to know if the popup should call AnimateViewIn() and AnimateViewOut(DismissType) methods or not.

    Declaration
    protected virtual bool ShouldAnimate()
    Returns
    Type Description
    bool

    True if you want to animate the popup, False otherwise.

    ShouldDismiss(DismissType)

    Check if the popup should be dismissed or not, depending on the reason.

    Declaration
    protected virtual bool ShouldDismiss(DismissType reason)
    Parameters
    Type Name Description
    DismissType reason

    Why the element has been dismissed.

    Returns
    Type Description
    bool

    True if the popup should be dismissed, False otherwise.

    Show()

    Show the Popup.

    Declaration
    public virtual void Show()

    ShowView()

    Called when the popup's Handler has received a k_PopupShow message. In this method the view should become visible at some point (directly or via an animation).

    Declaration
    protected virtual void ShowView()
    In This Article
    Back to top
    Copyright © 2025 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)