rap*_*2-h 0 c# coroutine unity-game-engine unity5
我有一个BonusController脚本作为BonusgameObject的一个组件.这个奖金必须在碰撞时销毁,但必须"行动"几秒钟.我为此启动了一个协同程序,但脚本停止执行(我认为这是因为我将gameObject设置为非活动状态).这是代码BonusController:
void OnTriggerEnter2D(Collider2D col)
{
    StartCoroutine(speedUp(1));
    gameObject.SetActive(false);
}
IEnumerator speedUp(float seconds)
{
    Debug.Log("before");
    yield return new WaitForSeconds(seconds);
    Debug.Log("after"); // <--- This is never called
}
如何删除对象并且不停止协程脚本执行?
| 归档时间: | 
 | 
| 查看次数: | 4018 次 | 
| 最近记录: |