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>
    BottomNotification<Toast>
    Toast
    Inherited Members
    BottomNotification<Toast>.animationMode
    BottomNotification<Toast>.isShown
    BottomNotification<Toast>.isShownOrQueued
    BottomNotification<Toast>.duration
    BottomNotification<Toast>.SetAnimationMode(AnimationMode)
    BottomNotification<Toast>.SetDuration(NotificationDuration)
    BottomNotification<Toast>.Dismiss(DismissType)
    BottomNotification<Toast>.Show()
    Popup<Toast>.shown
    Popup<Toast>.dismissed
    Popup<Toast>.SetKeyboardDismiss(bool)
    Popup<Toast>.SetLastFocusedElement(Focusable)
    Popup.keyboardDismissEnabled
    Popup.view
    Popup.targetParent
    Popup.contentView
    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 : BottomNotification<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

    triggeredActionId

    The Action ID of the triggered Action (if any) just before dismissing the element.

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

    Methods

    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
    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
    ArgumentException

    The provided view is not contained in a valid UI panel.

    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.

    SetAction(int, string, Action)

    Set an Action to display in the Toast bar.

    Declaration
    public Toast SetAction(int actionId, string msg, Action callback)
    Parameters
    Type Name Description
    int actionId

    The Action ID

    string msg

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

    Action callback

    The Action callback.

    Returns
    Type Description
    Toast

    The current toast.

    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)

    Declaration
    public Toast SetStyle(NotificationStyle notificationStyle)
    Parameters
    Type Name Description
    NotificationStyle notificationStyle
    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)