Created
November 7, 2019 08:58
-
-
Save beardordie/18bb3e01b0548503f444fa40841a4325 to your computer and use it in GitHub Desktop.
Corgi Engine simple component to subscribe to a MMGameEvent by string and trigger a UnityEvent with no parameters. You may also use this as a template for hooking into other event types included with the Corgi Engine
This file contains hidden or 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; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using MoreMountains.Tools; | |
using UnityEngine.Events; | |
public class MMGameEventToUnityEvent : MonoBehaviour, MMEventListener<MMGameEvent> | |
{ | |
public string MMGameEventName = ""; | |
public UnityEvent events; | |
void OnEnable() | |
{ | |
this.MMEventStartListening<MMGameEvent>(); | |
} | |
void OnDisable() | |
{ | |
this.MMEventStopListening<MMGameEvent>(); | |
} | |
public void OnMMEvent(MMGameEvent eventType) | |
{ | |
if (Equals(eventType.EventName, MMGameEventName)) | |
{ | |
events?.Invoke(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment