Created
May 18, 2020 16:18
-
-
Save ryanmillerca/3d6177e8cd5cb09b1dbf2b7fc81787bf to your computer and use it in GitHub Desktop.
Event Ferry (to connect Animation Events to UnityEvents)
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
// Event Ferry | |
// used to fake UnityEvent support into Animation Clip events. | |
// place on the gameObject with the Animator component | |
// call TriggerEvent with the index of the event previously specified | |
// Made by Ryan Miller (https://www.ryanmiller.ca) | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Events; | |
public class EventFerry : MonoBehaviour { | |
/// <summary> | |
/// Hook these up in inspector to create the target of your unity events | |
/// </summary> | |
public UnityEvent[] outgoingEvents; | |
/// <summary> | |
/// Trigger this from AnimationEvents | |
/// </summary> | |
public void TriggerEvent(int index){ | |
if (outgoingEvents.Length > index){ | |
outgoingEvents[index].Invoke(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment