版权声明:原创图片,自截图片,纯手打文字,经过允许才可转载!业余个人经验分享,有不足的地方请留言,或点【投票】以资鼓励;觉得帮了小忙,请点个赞;还可以点击分享;怕下次出问题之后忘记找不到,可点击收藏。谢谢合作。 https://blog.csdn.net/qq_40985921/article/details/86511337
俩种情况
1.开发测试的时候
可以在Game视图中点击Stats查看
2.发布后看FPS
新建一个脚本FPSDisplay.cs,拖到相机上。
using UnityEngine;
using System.Collections;
public class FPSDisplay : MonoBehaviour
{
float deltaTime = 0.0f;
void Update()
{
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
}
void OnGUI()
{
int w = Screen.width, h = Screen.height;
GUIStyle style = new GUIStyle();
Rect rect = new Rect(0, 0, w, h * 2 / 100);
style.alignment = TextAnchor.UpperLeft;
style.fontSize = h * 2 / 100;
//new Color (0.0f, 0.0f, 0.5f, 1.0f);
style.normal.textColor = Color.white;
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
GUI.Label(rect, text, style);
}
}