VR Notifications
It's a simple, easy-to-use Notification System for your wonderful VR project.
Initially, I developed this package for VR Boxel Editor.
How to install the package
Easy-peasy:
- Copy Git URL
- Open
Window/Package Manager
- Add VR Notifications package via
Add package from git URL
How to add it to your project
Super simple. Find the Notification Manager
prefab and drop it into your scene.
How to send a notification
I love binding SendMessage
to UnityEvents to make it decoupled as much as possible.
using System;
using UnityEngine.Events;
// Create a custom Unity Event
[Serializable]
public class NotificationEvent: UnityEvent<string> {}
using UnityEngine;
public class MyScript : MonoBehaviour
{
[SerializeField] private string MyMessage = "Space has been pressed.";
// Expose the custom Unity Event in the Editor
[SerializeField] private NotificationEvent MyEvent;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
MyEvent.Invoke(MyMessage);
}
}
}
Also, since Notification Manager
is Singleton
, you can call its methods without having a direct reference to the object. Very straightforward:
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
NotificationManager.Instance.SendMessage("Space has been pressed.");
}
}
How to set up
All properties are in a Scriptable Object Asset called "Notification Settings".
It is very useful to have multiple data assets when you tweak values a lot during the design iterations. You don't need to recompile the script each time you make changes.
To create Notification Settings
, go to Create
/ Create Notification Settings
. Then drop the asset to the Notification Manager
.
Contacts
Twitter | Linkedin | Dribbble | Personal Site