Created
February 15, 2020 19:00
-
-
Save wowbroforce/0c5e57d2af6a59d7d3ffd85849365f13 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 UnityEngine; | |
using System.Collections.Generic; | |
[CreateAssetMenu(fileName = "GameEvent", menuName = "~/Assets/Scripts/GameEvent", order = 0)] | |
public class GameEvent : ScriptableObject | |
{ | |
private List<GameEventListener> listeners = new List<GameEventListener>(); | |
public void Raise() | |
{ | |
for (var i = listeners.Count - 1; i >= 0; i--) | |
listeners[i].OnEventRised(); | |
} | |
public void Register(GameEventListener listener) | |
{ | |
listeners.Add(listener); | |
} | |
public void Unregister(GameEventListener listener) | |
{ | |
listeners.Remove(listener); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment