Notifications
Important
If you want to display more than one notification at the same time,
then notification container should have layout group component like EasyLayout
.
Start positions of notifications are determined with Group Position
.
Options
Hide Button
Button
Button to close notification.
Text
Text
(obsolete)GameObject to display the notification text. Replaced with NotifyInfo.
Hide Delay
float
Delay before notification automatically hidden.
Unscaled Time
bool
Delay with unscaled time.
Slide Up On Hide
bool
Start slide up animations after hide current notification. Turn it off if its managed with HideAnimation.
Notify Info
NotifyInfoBase
Component to display the notification message.
Close Button
Button
Button to close notification.
Buttons Container
RectTransform
Buttons container. If container not specified will be used parent of the button template.
Show() Method Parameters
message
also can be specified with SetMessage()
message
string
Notification message.Can be changed withSetMessage()
method.customHideDelay
float?
Time before notification hidden orhideAnimation
start running.Can be changed withHideDelay
field.container
Transform?
Notifications container. Should haveLayout Group
componentto display multiple notifications.Can be changed withSetContainer()
method.showAnimation
Func<TNotification, IEnumerator>
Show animation.Can be changed withShowAnimation
field.hideAnimation
Func<TNotification, IEnumerator>
Hide animation.Can be changed withHideAnimation
field.slideUpOnHide
bool?
Obsolete.UseEasyLayout.MovementAnimation
instead.sequenceType
NotifySequence
Add notification to sequence and display in order according to the specified
sequenceType
.sequenceDelay
float
Time between previous notification was hidden and this will be displayed.Can be changed withSequenceDelay
field.clearSequence
bool
Clear notifications sequence.
newUnscaledTime
bool?
Animations will use unscaled time.
content
RectTransform
Notification content.Can be changed withSetContent()
.onReturn
Action
Action called when instance return to the cache.Can be changed withOnReturn
field.onHide
Action<TNotification>
Action called when instance return to the cache.Can be changed withOnNotificationHide
field.
ShowAsync() Method Parameters
message
also can be specified with SetMessage()
-1
if notification was hidden after delay or on hide button click.message
string
Notification message.Can be changed withSetMessage()
method.customHideDelay
float?
Time before notification hidden orhideAnimation
start running.Can be changed withHideDelay
field.container
Transform?
Notifications container. Should haveLayout Group
componentto display multiple notifications.Can be changed withSetContainer()
method.showAnimation
Func<TNotification, IEnumerator>
Show animation.Can be changed withShowAnimation
field.hideAnimation
Func<TNotification, IEnumerator>
Hide animation.Can be changed withHideAnimation
field.slideUpOnHide
bool?
Start slide up animations after hide current notification.Can be changed withSlideUpOnHide
field.sequenceType
NotifySequence
Add notification to sequence and display in order according to the specified
sequenceType
.sequenceDelay
float
Time between previous notification was hidden and this will be displayed.Can be changed withSequenceDelay
field.clearSequence
bool
Clear notifications sequence.
newUnscaledTime
bool?
Animations will use unscaled time.
content
RectTransform
Notification content.Can be changed withSetContent()
.closeOnButtonClick
bool
Close notification on button click.
Minimal code
// get notification instance by template name (name of existing GameObject with NotificationBase component).
var notification = notificatetionTemplate.Clone();
// show notification
notification.Show();
Advanced
var notification = notificatetionTemplate.Clone();
// show notification
notification.Show(
// Show notification with following text
message: "Simple Notification.",
// Hide it after 4.5 seconds
customHideDelay = 4.5f,
// Run specified animation on hide
hideAnimation = NotificationBase.AnimationCollapseVertical,
// without SlideUpOnHide
slideUpOnHide = false
);
Default Hide Animations
Note
Hide Animation is coroutine that accepts NotificationBase
instance and play hide animation for this instance.
You can specify any custom coroutine.
- AnimationRotateHorizontal
Rotate notification on X axis.
- AnimationRotateVertical
Rotate notification on Y axis.
- AnimationCollapseHorizontal
Resize width of the notification.
- AnimationCollapseVertical
Resize height of the notification.
- AnimationSlideRight
Slide notification on right.
- AnimationSlideLeft
Slide notification on left.
- AnimationSlideUp
Slide notification on up.
- AnimationSlideDown
Slide notification on down.
Default Show Animations
Note
Show Animation is coroutine that accepts NotificationBase
instance and play show animation for this instance.
You can specify any custom coroutine.
- ShowAnimationRotateHorizontal
Rotate notification on X axis.
- ShowAnimationRotateVertical
Rotate notification on Y axis.
- ShowAnimationCollapseHorizontal
Resize width of the notification.
- ShowAnimationCollapseVertical
Resize height of the notification.
- ShowAnimationSlideRight
Slide notification from right.
- ShowAnimationSlideLeft
Slide notification from left.
- ShowAnimationSlideUp
Slide notification from top.
- ShowAnimationSlideDown
Slide notification from bottom.
Configurable Hide Animations
HideAnimationRotateBase
Arguments:
NotificationBase
notificationNotification instance.
bool
isHorizontalRotate in horizontal or vertical direction.
float
timeLengthLength of animations in seconds.
HideAnimationCollapseBase
Arguments:
NotificationBase
notificationNotification instance.
bool
isHorizontalResize in horizontal or vertical direction.
float
speedResize speed in points per second.
HideAnimationSlideBase
Arguments:
NotificationBase
notificationNotification instance.
bool
isHorizontalSlide in horizontal or vertical direction.
float
directionSlide direction, -1f for left/down, +1f for right/up.
float
speedSlide speed in points per second.
bool
animateReplacementAnimate other notifications.
NotificationTemplate.Clone().Show(
"Notification message.",
customHideDelay: 3f,
hideAnimation: x => NotificationBase.HideAnimationSlideBase(x, true, -1f, 200f, true)
);
Configurable Show Animations
ShowAnimationRotateBase
Arguments:
NotificationBase
notificationNotification instance.
bool
isHorizontalRotate in horizontal or vertical direction.
float
timeLengthLength of animations in seconds.
ShowAnimationCollapseBase
Arguments:
NotificationBase
notificationNotification instance.
bool
isHorizontalResize in horizontal or vertical direction.
float
speedResize speed in points per second.
ShowAnimationSlideBase
Arguments:
NotificationBase
notificationNotification instance.
bool
isHorizontalSlide in horizontal or vertical direction.
float
directionSlide direction, -1f for left/down, +1f for right/up.
float
speedSlide speed in points per second.
bool
animateReplacementAnimate other notifications.
NotificationTemplate.Clone().Show(
"Notification message.",
customHideDelay: 3f,
showAnimation: x => NotificationBase.ShowAnimationSlideBase(x, true, -1f, 200f, true)
);
Custom Notifications
You can create derived class with own methods.
public class MyNotify : NotificationCustom<MyNotify>
{
// ...
}