diff options
Diffstat (limited to 'marching/Assets/Scripts/Utils/FPSScript.cs')
-rw-r--r-- | marching/Assets/Scripts/Utils/FPSScript.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/marching/Assets/Scripts/Utils/FPSScript.cs b/marching/Assets/Scripts/Utils/FPSScript.cs new file mode 100644 index 0000000..9c9a444 --- /dev/null +++ b/marching/Assets/Scripts/Utils/FPSScript.cs @@ -0,0 +1,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); + } + } + +} |