纳金网

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

作者: 王者再临    时间: 2014-12-31 22:16
标题: 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://wwww.narkii.com/club/) Powered by Discuz! X2.5