我试图使用帮助函数为了使函数暂停几秒钟,但它不执行等待函数。在触发函数内部使用帮助函数
这就是我一直在使用的代码:
代码:
public class Triggers : MonoBehaviour {
IEnumerator wait(float seconds) {
Debug.Log("In wait");
yield return new WaitForSeconds(seconds);
Debug.Log("after wait");
}
void OnTriggerEnter(Collider _collider)
{
Debug.Log("Destroy");
gameObject.SetActive(false);
Debug.Log("Before wait");
wait(5);
Debug.Log("activate");
gameObject.SetActive(true);
}
}
我会很感激一些帮助。
干得好。感谢您发布最终结果。 ;-) –