using UnityEngine;
using System.Collections;
using System;
using System.ComponentModel;
///
/// 封装协程,提供便捷使用方式
///
public sealed class CoroutineWrapper : MonoSingleton
{
///
/// 延迟n帧执行
///
///
///
///
IEnumerator ExeDelay(int frames, Action ev)
{
for (int i = 0; i < frames; i++)
{
yield return new WaitForEndOfFrame();
}
ev();
}
///
/// 延迟n秒执行
///
///
///
///
IEnumerator ExeDelayS(float sec, Action ev)
{
yield return new WaitForSeconds(sec);
ev();
}
///
/// 延迟n秒后执行
///
///
///
public void EXEDelaySecs(float sec, Action ev)
{
StartCoroutine(ExeDelayS(sec, ev));
}
///
/// 延迟n帧后执行
///
///
///
public void EXEDelayFrames(int frames, Action ev)
{
StartCoroutine(ExeDelay(frames, ev));
}
///
/// 每帧通知
///
public event Action OnPerFrame;
void Update()
{
OnPerFrame?.Invoke();
}
}