using TriInspector; using UnityEngine; using UnityEngine.Events; namespace R0bbie.Timeline { /// /// Command for simply invoking a Unity event /// [AddComponentMenu("Timeline/Commands/Invoke Unity Event (Step Command)")] [RequireComponent(typeof(Step))] public class InvokeEventCmd : StepCmd { // Exposed Variables [Title("Event")] [SerializeField] UnityEvent commandEvent; /// /// Initialise the command /// protected override void Init() { init = true; } /// /// Do whatever this command is designed to do /// /// public override void Activate(Step _parentStep) { base.Activate(_parentStep); // Play the event commandEvent?.Invoke(); // Immediately complete command now event invoked Complete(); } /// /// Do any cleanup stuff here, resetting command state, clearing garbage, etc. Called by parent StepCmd after Complete, should never be called within child command itself /// protected override void Cleanup() { active = false; } } }