纳金网

标题: Unity3d 固定一段时间进入的方法 [打印本页]

作者: may    时间: 2015-6-28 02:42
标题: Unity3d 固定一段时间进入的方法
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.     }

  17. }
复制代码





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