Skip to content

Instantly share code, notes, and snippets.

@theWill
Created November 28, 2017 23:25
Show Gist options
  • Save theWill/ac8966c0322a22e318fd32bd779ba094 to your computer and use it in GitHub Desktop.
Save theWill/ac8966c0322a22e318fd32bd779ba094 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using UnityEngine;
namespace faunlily
{
[CreateAssetMenu]
public class GameEvent : ScriptableObject
{
private List<GameEventListener> listeners = new List<GameEventListener>();
public object data;
public void Raise()
{
for (int i = listeners.Count - 1; i >= 0; i--)
{
//Debug.Log("event raised from " + this.name);
listeners[i].OnEventRaised();
}
}
public void RegisterListener(GameEventListener listener)
{
listeners.Add(listener);
}
public void UnregisterListener(GameEventListener listener)
{
listeners.Remove(listener);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment