namespace Zinnia.Event.Yield
{
using System.Collections;
using UnityEngine;
using Zinnia.Extension;
///
/// Yields after the have passed in scaled time by .
///
public class WaitForSecondsYieldEmitter : YieldEmitter
{
[Tooltip("The number of seconds to wait before yielding.")]
[SerializeField]
private float secondsToWait;
///
/// The number of seconds to wait before yielding.
///
public float SecondsToWait
{
get
{
return secondsToWait;
}
set
{
secondsToWait = value;
if (this.IsMemberChangeAllowed())
{
OnAfterSecondsToWaitChange();
}
}
}
///
/// The instruction to yield upon.
///
protected WaitForSeconds yieldInstruction;
///
protected override IEnumerator YieldOn()
{
yield return yieldInstruction;
}
protected virtual void OnEnable()
{
OnAfterSecondsToWaitChange();
}
///
/// Called after has been changed.
///
protected virtual void OnAfterSecondsToWaitChange()
{
yieldInstruction = new WaitForSeconds(SecondsToWait);
}
}
}