From d2a574ba76c56c340d8ac0ad841344664bc2cc59 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 8 May 2023 18:40:58 +0800 Subject: + misc --- marching/Assets/Scripts/Utils/FPSScript.cs | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 marching/Assets/Scripts/Utils/FPSScript.cs (limited to 'marching/Assets/Scripts/Utils/FPSScript.cs') 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 + { + /// + /// Delta time + /// + float deltaTime = 0.0f; + + /// + /// It will be used for printing out fps text on screen + /// + Text text; + + void Start() + { + text = GetComponent(); + } + + 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); + } + } + +} -- cgit v1.1-26-g67d0