Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class EventManager : MonoBehaviour {
- public delegate void PowerUpHandler (bool isPoweredUp);
- public static event PowerUpHandler onPoweredUp;
- public void PowerUp () {
- if (onPoweredUp != null)
- onPoweredUp (true);
- }
- public void PowerOff () {
- if (onPoweredUp != null)
- onPoweredUp (false);
- }
- }
- public class EventListener : MonoBehaviour {
- void OnEnable () {
- EventManager.onPoweredUp += OnPoweredChange;
- }
- void OnDisable () {
- EventManager.onPoweredUp -= OnPoweredChange;
- }
- void OnPoweredChange (bool isPoweredUp){
- print (isPoweredUp? "Powered" : "Unpowered");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement