用c#协程有什么办法能暂停么?我只看见stop。
写了个分几轮出怪的协程,协程正常运行,但忽然发现无法暂停这个协程,用Stop就完全中断,再Start又重新开始。
不知有什么办法能让它暂停么?文中粗体字标记了重点。
求救,谢谢。
不知有什么办法能让它暂停么?文中粗体字标记了重点。
求救,谢谢。
public float roundIntervalTime = 3f;
public float spawIntervalTime = 1f;
IEnumerator RunRound()
{
if (isPause)
{
yield return null;
//有什么办法暂停
}
//SpawnMonsterArgs e = new SpawnMonsterArgs();
for (int r = 0; r < lstRound.Count; r++)
{
//这里可以加入StartRound事件,例如可触发最后一波
roundIndex = r;
for (int i = 0; i < lstRound[r].monsterCount; i++)
{
//e.monsterID = lstRound[r].monsterID;
//SendEvent(Consts.E_SpawnMonster, e);
if (r == (lstRound.Count - 1) && (i == lstRound[r].monsterCount - 1))
{
Debug.Log(" round is end !");
}
else
{
Debug.Log("Round: r:" + r + ", i:" + i);
}
yield return new WaitForSeconds(spawIntervalTime);
}
yield return new WaitForSeconds(roundIntervalTime);
}
}
public void StartRound()
{
coroutine= Game.Instance.StartCoroutine(RunRound());
Debug.Log("RoundModel.StartRound()");
}
public void StopRound()
{
//Game.Instance.StopCoroutine(coroutine);
isPause = !isPause;
Debug.Log("isPause: "+isPause);
}
...全文
相关推荐
C#语音朗读类(播放、停止、暂停、继续)
用C#写的实现语音朗读播放、停止、暂停、继续功能,支持中英文朗读,精典实例,可以直接使用。如在使用过程中有问题或改进,可以发Email:liubingchao@126.com;互相交流与学习。
基于C#实现多线程启动停止暂停继续
基于C#实现多线程启动停止暂停继续
线程暂停、开始、结束
关于线程暂停、开始、结束的一个演示Demo
WPF+C# 实现视频播放器最全功能(视频的进度条,截屏,视频定位。。)
实现的功能有:视频播放器播放的进度条,截屏,暂停,停止,静音,音量,视频定位
C#使用videoSourcePlayer控件实现拍照录像功能
C#使用videoSourcePlayer控件实现拍照录像功能,添加videoSourcePlayer控件,再放置图片控件用来保存临时拍照的照片


