Created
November 28, 2017 23:25
-
-
Save theWill/ac8966c0322a22e318fd32bd779ba094 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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