docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Toast

    A toast is a view containing a quick little message for the user.

    Inheritance
    object
    Popup
    Popup<Toast>
    PopupNotification<Toast>
    Toast
    Inherited Members
    PopupNotification<Toast>.animationMode
    PopupNotification<Toast>.isShown
    PopupNotification<Toast>.isShownOrQueued
    PopupNotification<Toast>.duration
    PopupNotification<Toast>.position
    PopupNotification<Toast>.SetAnimationMode(AnimationMode)
    PopupNotification<Toast>.SetDuration(NotificationDuration)
    PopupNotification<Toast>.SetPosition(PopupNotificationPlacement)
    PopupNotification<Toast>.Dismiss(DismissType)
    PopupNotification<Toast>.Show()
    Popup<Toast>.shown
    Popup<Toast>.dismissed
    Popup<Toast>.SetContainerView(VisualElement)
    Popup<Toast>.SetKeyboardDismiss(bool)
    Popup<Toast>.SetLastFocusedElement(Focusable)
    Popup.keyboardDismissEnabled
    Popup.view
    Popup.containerView
    Popup.referenceView
    Popup.contentView
    Popup.rootView
    Popup.Dismiss()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.UI
    Assembly: Unity.AppUI.dll
    Syntax
    public sealed class Toast : PopupNotification<Toast>

    Properties

    icon

    The icon used inside the Toast as leading UI element.

    Declaration
    public string icon { get; }
    Property Value
    Type Description
    string

    style

    Returns the styling used by the bar. See NotificationStyle for more information.

    Declaration
    public NotificationStyle style { get; }
    Property Value
    Type Description
    NotificationStyle

    text

    Returns the raw message or Localization dictionary key used by the bar.

    Declaration
    public string text { get; }
    Property Value
    Type Description
    string

    Methods

    AddAction(int, string, Action<Toast>, bool)

    Add an Action to display in the Toast bar.

    Declaration
    public Toast AddAction(int actionId, string message, Action<Toast> callback, bool autoDismiss = true)
    Parameters
    Type Name Description
    int actionId

    The Action ID, which is a unique identifier for your action.

    string message

    The raw message or Localization dictionary key for the action to be displayed.

    Action<Toast> callback

    The callback which will be called when the action is triggered.

    bool autoDismiss

    Whether the toast should be dismissed automatically after the action is triggered.

    Returns
    Type Description
    Toast

    The Toast instance, if no exception has occured.

    Build(VisualElement, string, NotificationDuration)

    Build and return a Toast UI element.

    The method will find the best suitable parent view which will contain the Toast element.

    Declaration
    public static Toast Build(VisualElement referenceView, string text, NotificationDuration duration)
    Parameters
    Type Name Description
    VisualElement referenceView

    An arbitrary VisualElement which is currently present in the UI panel.

    string text

    The raw message or Localization dictionary key for the message to be displayed inside the Toast.

    NotificationDuration duration

    A duration enum value.

    Returns
    Type Description
    Toast

    The Toast instance, if no exception has occured.

    Remarks

    The snackbar is not displayed directly, you have to call Show().

    Exceptions
    Type Condition
    ArgumentNullException

    If referenceView is null.

    HideView(DismissType)

    Called when it is time to hide the popup.

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

    The reason why the popup should be dismissed.

    Overrides
    Popup.HideView(DismissType)

    InvokeShownEventHandlers()

    Called when the popup has become visible. This method will invoke any handlers attached to the shown event.

    Declaration
    protected override void InvokeShownEventHandlers()
    Overrides
    PopupNotification<Toast>.InvokeShownEventHandlers()

    RemoveAction(int)

    Remove an already existing action.

    Declaration
    public Toast RemoveAction(int actionId)
    Parameters
    Type Name Description
    int actionId

    The Action ID.

    Returns
    Type Description
    Toast

    The Toast instance, if no exception has occured.

    SetIcon(string)

    Set a new value for the icon property.

    Declaration
    public Toast SetIcon(string iconName)
    Parameters
    Type Name Description
    string iconName

    The name of the icon.

    Returns
    Type Description
    Toast

    The Toast to continuously build the element.

    SetStyle(NotificationStyle)

    Set the styling used by the bar.

    Declaration
    public Toast SetStyle(NotificationStyle notificationStyle)
    Parameters
    Type Name Description
    NotificationStyle notificationStyle

    A notification style enum value. See NotificationStyle for more information.

    Returns
    Type Description
    Toast

    The Toast to continuously build the element.

    SetText(string)

    Update the text in the Toast.

    Declaration
    public Toast SetText(string txt)
    Parameters
    Type Name Description
    string txt

    The raw message or Localization dictionary key for the message to be displayed.

    Returns
    Type Description
    Toast

    The Toast to continuously build the element.

    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)