Class Toast
A toast is a view containing a quick little message for the user.
Inherited Members
Namespace: UnityEngine.Dt.App.UI
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 |
---|---|
Int32 |
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(Int32)
Remove an already existing action.
Declaration
public Toast RemoveAction(int actionId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | actionId | The Action ID. |
Returns
Type | Description |
---|---|
Toast | The Toast instance, if no exception has occured. |
SetAction(Int32, 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 |
---|---|---|
Int32 | 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. |