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

    1. using UnityEngine;  
    2. using System.Collections;  
    3. public class NewBehaviourScript : MonoBehaviour {  
    4. // Use this for initialization  
    5. void Start () {  
    6.    InvokeRepeating("LaunchProjectile", 1,5);//1秒后调用LaunchProjectile () 函数,之后每5秒调用一次  
    7. }  
    8. // Update is called once per frame  
    9. void Update () {  
    10.    if (Input.GetButton ("Fire")) {  
    11.     CancelInvoke();  
    12.    }  
    13. }  
    14. void LaunchProjectile () {  
    15.    print("hello");  
    16. }  

posted @ 2012-05-15 10:18  渡蓝  阅读(607)  评论(0)    收藏  举报