1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MainG : MonoBehaviour {
[SerializeField]
private Text FramePerSecond;
private float fps;
public int FPS = 0;
void Start (){
FramePerSecond.transform.localPosition = new Vector3 (2000, 493, 0);
FPS = 0;
}
void Update () {
if (FPS == 0 && Input.GetKeyDown (KeyCode.P)) {
FramePerSecond.transform.localPosition = new Vector3 (822, 493, 0);
FPS = 1;
}
if (FPS == 1 && Input.GetKeyDown (KeyCode.P)) {
FramePerSecond.transform.localPosition = new Vector3 (2000, 493, 0);
FPS = 0;
}
fps = (9.0f * fps + 1.0f / Time.deltaTime) / 10.0f;
FramePerSecond.text = "FPS : " + (int)fps;
}
} |
Partager