56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using TriInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace R0bbie.Timeline
|
|
{
|
|
/// <summary>
|
|
/// Command for simply invoking a Unity event
|
|
/// </summary>
|
|
[AddComponentMenu("Timeline/Commands/Invoke Unity Event (Step Command)")]
|
|
[RequireComponent(typeof(Step))]
|
|
public class InvokeEventCmd : StepCmd
|
|
{
|
|
// Exposed Variables
|
|
|
|
[Title("Event")]
|
|
[SerializeField] UnityEvent commandEvent;
|
|
|
|
|
|
/// <summary>
|
|
/// Initialise the command
|
|
/// </summary>
|
|
protected override void Init()
|
|
{
|
|
init = true;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Do whatever this command is designed to do
|
|
/// </summary>
|
|
/// <param name="_parentStep"></param>
|
|
public override void Activate(Step _parentStep)
|
|
{
|
|
base.Activate(_parentStep);
|
|
|
|
// Play the event
|
|
commandEvent?.Invoke();
|
|
|
|
// Immediately complete command now event invoked
|
|
Complete();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
protected override void Cleanup()
|
|
{
|
|
active = false;
|
|
}
|
|
|
|
|
|
}
|
|
}
|