0
我是Unity開發人員的新成員,我開始學習閱讀教程,演示,示例和視頻的Unity。和我有一些麻煩,使用定時器(如在團結線,我想這...),這裏是我的代碼:統一產量waitfreescond不工作
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);
}
我不知道爲什麼....
被燒燬了嗎?我在問,因爲我在實踐中對產量報表感到困惑。如果交換Debug.log()和destroy語句,是否顯示文本? – MVCDS 2014-10-16 11:55:25
是的。 debug.log()後,銷燬語句不運行,我認爲產量不運行:( – kemdo 2014-10-16 12:13:04
產量WaitForSeconds(1)導致問題,需要yeild retun新waitforsecond(); – kemdo 2014-10-16 13:05:18