我是Unity开发人员的新手,我开始通过阅读教程,演示,示例和视频来学习Unity。我在使用计时器时遇到了一些麻烦(比如统一线程,我猜它......),这是我的代码:
void OnCollisionEnter(Collision colli){
if (colli.collider.name == "Car") {
Debug.Log("On Collision naz ~.~");
Destroy(Car);
Destroy(this.gameObject);
GameObject clone = (GameObject) Instantiate(Bum, transform.position, Quaternion.identity);
StartCoroutine(deleteObject(clone));
// Just want to delete "clone" object after 1 second
}
}
IEnumerator deleteObject(GameObject bum){
Debug.Log("chuan bi destroy naz ~.~"); // <-- run normally
yield return new WaitForSeconds(1.0F);
Debug.Log("Destroy rui naz =,='"); // <-- not display
Destroy (bum);
}
我不知道为什么......
答案 0 :(得分:1)