Giter Site home page Giter Site logo

volorf / vr-notifications Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 2.79 MB

Simple Notification System for VR.

License: MIT License

C# 100.00%
notification package unity3d vr xr alert csharp message popup prototyping snackbar prototypes unity virtual-reality unity-3d

vr-notifications's Introduction

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:

  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.

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

vr-notifications's People

Contributors

volorf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.