Skip to content

Instantly share code, notes, and snippets.

@beardordie
Created November 7, 2019 08:58
Show Gist options
  • Save beardordie/18bb3e01b0548503f444fa40841a4325 to your computer and use it in GitHub Desktop.
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
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