https://github.com/volorf/vr-notifications
Simple Notification System for VR.
https://github.com/volorf/vr-notifications
alert csharp message notification package popup prototypes prototyping snackbar unity unity-3d unity3d virtual-reality vr xr
Last synced: 6 months ago
JSON representation
Simple Notification System for VR.
- Host: GitHub
- URL: https://github.com/volorf/vr-notifications
- Owner: Volorf
- License: mit
- Created: 2022-09-17T16:46:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-09T19:48:19.000Z (over 1 year ago)
- Last Synced: 2025-04-03T21:11:12.211Z (11 months ago)
- Topics: alert, csharp, message, notification, package, popup, prototypes, prototyping, snackbar, unity, unity-3d, unity3d, virtual-reality, vr, xr
- Language: C#
- Homepage:
- Size: 2.7 MB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://twitter.com/Volorf/status/1305406161710125056).
# How to install the package
Easy-peasy:
1. Copy Git URL
2. Open `Window/Package Manager`
3. 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.
```csharp
using System;
using UnityEngine.Events;
// Create a custom Unity Event
[Serializable]
public class NotificationEvent: UnityEvent {}
```
```csharp
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:
```csharp
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](https://www.twitter.com/volorf) | [Linkedin](https://www.linkedin.com/in/oleg-frolov-6a6a4752/) | [Dribbble](https://dribbble.com/Volorf) | [Personal Site](https://olegfrolov.design/)