Unity3d 固定一段时间进入某个方法

来源:互联网 发布:淘宝库克运动是正品吗 编辑:程序博客网 时间:2024/05/22 15:44

  • using UnityEngine;  
  • using System.Collections;  
  • public class NewBehaviourScript : MonoBehaviour {  
  • // Use this for initialization  
  • void Start () {  
  •    InvokeRepeating("LaunchProjectile", 1,5);//1秒后调用LaunchProjectile () 函数,之后每5秒调用一次  
  • }  
  • // Update is called once per frame  
  • void Update () {  
  •    if (Input.GetButton ("Fire")) {  
  •     CancelInvoke();  
  •    }  
  • }  
  • void LaunchProjectile () {  
  •    print("hello");  
  • }  
  • }

    本文来自:http://blog.csdn.net/zhulinpptor/article/details/5876710