unity3D延迟函数

1.Invoke(string methodName,float time)

  • 在一定时间调用methodName函数
    using UnityEngine;
    using System.Collections;
      
    public class example : MonoBehaviour {
        函数
        public void Awake() {
            Invoke("函数名",时间);
        }
    }    

    2.InvokeRepeating(string methodName,float time,float repeatRate)

  • 每隔一定时间调用一次methodName函数
  • 在time秒调用methodName方法;简单说,根据时间调用指定方法名的方法
  • 从第一次调用开始,每隔repeatRate时间调用一次.
    using UnityEngine;
    using System.Collections;
      
    public class example : MonoBehaviour {
        函数
        public void Awake() {
       InvokeRepeating("函数名",时间,时间间隔);
    }
    }    

    3.CanceInvoke("methodName")

  •   取消所有名为methodName的调用.
原文地址:https://www.cnblogs.com/lichuangblog/p/6692310.html