Class Toaster
The viewport that renders the ToastManager stack, anchored to a corner or an edge of its parent.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class Toaster : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
Remarks
Mount one Toaster per UI panel that should display toasts, then post from anywhere with Add(string, NotificationStyle, string). The host only renders: it owns no queue of its own, so several hosts stay in sync and a host that is removed from the hierarchy stops tracking the stack.
Toasts are laid out newest first, growing away from the anchored edge. Each one is the same visual element a Toast popup uses, so the two channels look identical.
Examples
Mounting a host in C#.
panel.Add(new Toaster { anchor = PopupNotificationPlacement.TopEnd, limit = 5 });
Declaring one in UXML.
<UXML>
<appui:Toaster anchor="BottomRight" limit="3" />
</UXML>
Constructors
Toaster()
Default constructor.
Declaration
public Toaster()
Fields
anchorUssClassName
The prefix of the anchor styling classes, for instance appui-toaster--bottomright.
Declaration
public const string anchorUssClassName = "appui-toaster--"
Field Value
| Type | Description |
|---|---|
| string |
exitingUssClassName
The class a toast carries while it plays its exit transition. It is no longer part of the stack, and is removed from the hierarchy once the transition ends.
Declaration
public const string exitingUssClassName = "appui-toaster__toast--exiting"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The main styling class of the Toaster.
Declaration
public const string ussClassName = "appui-toaster"
Field Value
| Type | Description |
|---|---|
| string |
Properties
anchor
Which corner or edge of the parent the toast stack anchors to. Defaults to BottomRight.
Declaration
[Tooltip("Which corner or edge of the parent the toast stack anchors to.")]
[CreateProperty]
[UxmlAttribute]
[Header("Toaster")]
public PopupNotificationPlacement anchor { get; set; }
Property Value
| Type | Description |
|---|---|
| PopupNotificationPlacement |
limit
How many toasts stack at once. This is a view over the global limit, so setting it here changes the depth for every host.
Declaration
[Tooltip("How many toasts stack at once.")]
[CreateProperty]
[UxmlAttribute]
public int limit { get; set; }
Property Value
| Type | Description |
|---|---|
| int |