Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 3 months ago
JSON representation

Simple Notification System for VR.

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/)