blob: 9c9a44416d5a7cbcc565d441eaa511020492e1a8 (
plain)
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
|
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
namespace FBCapture
{
public class FPSScript : MonoBehaviour
{
/// <summary>
/// Delta time
/// </summary>
float deltaTime = 0.0f;
/// <summary>
/// It will be used for printing out fps text on screen
/// </summary>
Text text;
void Start()
{
text = GetComponent<Text>();
}
void Update()
{
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
text.text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
}
}
}
|