All Projects → jheiling → Unity Signals

jheiling / Unity Signals

Licence: mit
Signals for Unity3D

Projects that are alternatives of or similar to Unity Signals

Noahgameframe
A fast, scalable, distributed game server engine/framework for C++, include the actor library, network library, can be used as a real time multiplayer game engine ( MMO RPG/MOBA ), which support C#/Lua script/ Unity3d, Cocos2dx and plan to support Unreal.
Stars: ✭ 3,258 (+10081.25%)
Mutual labels:  unity, unity3d, architecture
Testbedhdrp
Testbed project for Unity HDRP (High Definition Render Pipeline)
Stars: ✭ 859 (+2584.38%)
Mutual labels:  unity, unity3d
Savegamepro
A Complete and Powerful Save Game Solution for Unity (Game Engine)
Stars: ✭ 30 (-6.25%)
Mutual labels:  unity, unity3d
Museum
Live coding rig for Channel 18 at SuperDeluxe
Stars: ✭ 30 (-6.25%)
Mutual labels:  unity, unity3d
Unitystationbumper
Video bumper for Unity's live streaming channel.
Stars: ✭ 28 (-12.5%)
Mutual labels:  unity, unity3d
Ocean community next gen
Next gen iteration of the unity community ocean shader
Stars: ✭ 855 (+2571.88%)
Mutual labels:  unity, unity3d
Shadergraphexamples
Simple examples of Unity shader graphs.
Stars: ✭ 869 (+2615.63%)
Mutual labels:  unity, unity3d
Uduino
Simple and easy connection between Arduino and Unity
Stars: ✭ 25 (-21.87%)
Mutual labels:  unity, unity3d
Beaverandfairies
Stars: ✭ 14 (-56.25%)
Mutual labels:  unity, unity3d
Pix2pix
Real-time pix2pix implementation with Unity
Stars: ✭ 912 (+2750%)
Mutual labels:  unity, unity3d
Hsplugins
Various Honey Select plugins
Stars: ✭ 21 (-34.37%)
Mutual labels:  unity, unity3d
Unitynativescripting
Unity Scripting in C++
Stars: ✭ 844 (+2537.5%)
Mutual labels:  unity, unity3d
Shaderlabvs
ShaderlabVS is a Visual Studio plugin for Unity Shaderlab programming
Stars: ✭ 841 (+2528.13%)
Mutual labels:  unity, unity3d
Ubernet
Flexible networking library for Unity
Stars: ✭ 10 (-68.75%)
Mutual labels:  unity, unity3d
Pokemonunity
A framework to build Pokémon RPG games.
Stars: ✭ 934 (+2818.75%)
Mutual labels:  unity, unity3d
Unityprojecttreegenerator
This script will generate universal folder structure for your Unity3D project.
Stars: ✭ 12 (-62.5%)
Mutual labels:  unity, unity3d
Seido
Visuals for Matsuura Masaya's live performance in Osaka and Tokyo.
Stars: ✭ 31 (-3.12%)
Mutual labels:  unity, unity3d
Tower Defense Game
this is a game made with Unity, the goal is to protect the tower against robots.
Stars: ✭ 25 (-21.87%)
Mutual labels:  unity, unity3d
Voxelengine unity
Voxel engine made in C# for Unity
Stars: ✭ 25 (-21.87%)
Mutual labels:  unity, unity3d
C Sharp Promise
Promises library for C# for management of asynchronous operations.
Stars: ✭ 870 (+2618.75%)
Mutual labels:  unity, unity3d

Signals For Unity3D v2.0.2

Documentation

You can find the API documentation here.

What Are Signals?

A Signal is a ScriptableObject which holds a value and triggers a UnityEvent when a new value is assigned.

Why Should I Use Them?

Because ScriptableObjects are a good choice to create a sane architecture for games made with Unity. They allow you to nicely decouple systems and avoid direct references between scene objects. For an in depth explanation I would highly recommend watching Richard Fine's and Ryan Hipple's talks.

If you store a value in a ScriptableObject you might want to get notified when the value changes. On the other hand it can be useful to keep the last value an event was invoked with around. Signals are a solution for both use cases.

Installation

Copy everything somewhere into your project's Asset folder.

Usage

Implementing A Signal

First you need to create a class for the signal's OnChanged event:

[System.Serializable]
public class FloatEvent : UnityEvent<float> { }

Next create a class for the signal:

[UnityEngine.CreateAssetMenu]
public class FloatSignal : Signal<float, FloatEvent> { }

By default signals will trigger the OnChanged event whenever a new value is assigned. By overriding the ValidateValue method you can validate the value and/or add a check to avoid unnecessarily triggering the event. By default ValidateValue will use the Equals method for this check.

If you want to have a nice inspector create an editor class for your signal and override the ValueField method:

[UnityEditor.CustomEditor(typeof(FloatSignal))]
public class FloatSignalEditor : SignalEditor<float, FloatEvent>
{
    protected override float ValueField(float value)
    {
        return EditorGUILayout.DelayedFloatField(value);
    }
}

Implementing A SignalListener

By inheriting from SignalListener you can create a Component that listens to a signal's OnChanged event and propagates it:

public class FloatSignalListener : SignalListener<float, FloatEvent, FloatSignal> { }

Implementing A ValueReference

By inheriting from ValueReference you can use serializable fields in your scripts that can either hold a local value or a reference to a signal's value:

[System.Serializable]
public class FloatValueReference : ValueReference<float, FloatEvent, FloatSignal> 
{
    public FloatValueReference() { }
    public FloatValueReference(float localValue) : base(localValue) { }
}

And to make it look nice in the editor:

[UnityEditor.CustomPropertyDrawer(typeof(FloatValueReference))]
public class FloatValueReferenceDrawer : ValueReferenceDrawer { }

Code Generation

You can find a simple code generator that can save you a lot of work here.

Examples

See Examples folder.

Credits

Signals was inspired by Ryan Hipple's talk about game architecture with ScriptableObjects.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].