Overview
In-Game Notifications is a system to manage and display in-game notifications in an easy and simple way. The system provides many capabilities and is fast and efficient. The system is highly customizable, so you can tailor it to fit your needs. In-Game Notifications is a great way to keep your players informed and engaged.
Features:
- Position in screen corners
- Awake effects:
- Fade in
- Slide in
- Dismiss triggers:
- Timed
- On click
- Dismiss effects:
- Fade out
- Slide out
- Control the number of visible notifications
- Queue additional notifications
- Support custom UI for notifications (2 sample templates included in the asset)
- Support extendable notifications
Purchase In-Game Notifications from the Unity Assets Store here >>
Screenshots
Documentation
Code base
In-Game Notification’s code base is centered around the NotificationsManager
, which provides method to Add and Remove notification. The class exposes the following settings, that controls the way notifications are displayed:
Corner
: This property controls the corner of the screen where notifications will be displayedmaxVisibleNotificationsCount
andqueueNotifications
: These properties control how many notifications to show at any given time, and whether to queue any additional notificationsdefaultNotificationPrefab
: This will be the default template for notifications, in case no other template was provided when the notification was added. EithernotificationPrefabSize
ordefaultNotificationPrefab
must be provided.notificationPrefabSize
: This is the expected size of notifications. EithernotificationPrefabSize
ordefaultNotificationPrefab
must be provided.awakeEffect
,dismissTrigger
,dismissEffect
: These properties control the behavior of a notification as it’s being displayed, what triggers its dismissal, and how it disappears.
NotificationRenderer
is the base script responsible for displaying notifications. In addition, there are multiple scripts that affect the notifications’ behavior:
- Awake effects control the way the notification will behave upon appearance (e.g., fade in, slide in)
NOTE: Awake Effects are added to the notification object itself. - Dismiss triggers control the dismissal of the notification (e.g., after a certain timeout, when a button is clicked)
NOTE: Dismiss triggers are added to the notification container object (the parent of the notification object). - Dismiss effects control the way the notification will behave upon dismissal (e.g., fade out, slide out)
NOTE: Dismiss Effects are added to the notification object itself.
Using In-Game Notifications
Passing more information in a notification
A notification consists of a “title”, a “description”, and any number of additional properties. Developers can easily pass more information as part of the notification, which can be later handled by the renderer:
Notification notification = new Notification()
{
title = "Sample" + count++,
description = "Sample description",
properties = new Dictionary<string, object>
{
{ "icon", notificationsIcon },
{ "backgroundColor", Color.green },
}
};
Creating a custom template
In order display a custom template, first create a new Renderer, which inherits from the NotificationRenderer
script:
public class MyNotificationRenderer : NotificationRenderer
Override the SetNotification
method, to assign details provided from the Notification to the Renderer:
public override void SetNotification(NotificationsManager notificationsManager, Notification notification)
{
this.notificationsManager = notificationsManager;
title.text = notification.title;
description.text = notification.description;
icon.sprite = (Sprite)notification.properties["icon"];
background.color = (Color)notification.properties["backgroundColor"];
}
Next, create a new GameObject
, and assign it the above Renderer. Your object should now be saved as