WaitForSeconds.WaitForseconds等待函数;
创建一个yield指令,来等待给定的秒数;
1 using UnityEngine; 2 using System.Collections; 3 4 public class example:MonoBehaviour 5 { 6 public IEnumerator Awake() 7 { 8 print(Time.time); 9 yield return new WaitForSeconds(5); 10 print(Time.time); 11 } 12 }
WaitForSeconds.WaitForSeconds
注:
1、必须添加接口IEnumerator,
2、等待函数只能写在接口内;
时间: 2024-10-29 19:05:45