纳金网

标题: Unity3d 程序定时器 [打印本页]

作者: 狂风大尉    时间: 2014-9-30 23:24
标题: Unity3d 程序定时器
unity3d 固定一段时间进入某个方法

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");  
}  
}  
作者: hyui    时间: 2014-10-1 16:12
great to know !              




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5