上传文件至 Common
This commit is contained in:
28
Common/ShowFPS.cs
Normal file
28
Common/ShowFPS.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SinmaiAssist.Common;
|
||||
|
||||
public class ShowFPS
|
||||
{
|
||||
private static string fpsText = "FPS: ";
|
||||
private static float deltaTime = 0.0f;
|
||||
|
||||
public static void OnGUI()
|
||||
{
|
||||
Update();
|
||||
GUIStyle style = new GUIStyle();
|
||||
style.fontSize = 24;
|
||||
style.normal.textColor = Color.black;
|
||||
style.alignment = TextAnchor.UpperLeft;
|
||||
UnityEngine.GUI.Label(new Rect(10 + 2, 10 + 2, 500, 30), fpsText, style);
|
||||
style.normal.textColor = Color.white;
|
||||
UnityEngine.GUI.Label(new Rect(10, 10, 500, 30), fpsText, style);
|
||||
}
|
||||
|
||||
private static void Update()
|
||||
{
|
||||
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
|
||||
float fps = 1.0f / deltaTime;
|
||||
fpsText = $"FPS: {Mathf.Ceil(fps)}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user