Skip to content

Instantly share code, notes, and snippets.

@johans2
Created September 9, 2018 15:41
Show Gist options
  • Save johans2/1baf841381ae389d85df14fab1ab7f14 to your computer and use it in GitHub Desktop.
Save johans2/1baf841381ae389d85df14fab1ab7f14 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class SignalListener : MonoBehaviour {
public int maxNum = 5;
void Start () {
Debug.Log(ToString() + "Adding listener..");
SignalSender.TestSignal.AddListener(OnSignal);
}
private void OnSignal(string text, int number) {
if(number > maxNum) {
Debug.Log(ToString() + " Removing listener..");
SignalSender.TestSignal.RemoveListener(OnSignal);
}
else {
Debug.Log(ToString() + " GOT NOTIFICATION -> text: " + text + " number: " + number);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment