博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
游戏中,显示FPS
阅读量:7005 次
发布时间:2019-06-27

本文共 769 字,大约阅读时间需要 2 分钟。

hot3.png

游戏 stats可以显示,但是打包运行无法查看,所以我们可以手动计算FPS

FPS= 1/当前帧所花时间

编辑器新建一个 UI.Text  

添加以下C#脚本

using UnityEngine;using System.Collections;using UnityEngine.UI;public class fpsScript : MonoBehaviour {	public float m_time;	public Text text;	public float delay=0.0f;	public int m_count=0;	// Use this for initialization	void Start () {		Application.targetFrameRate=-1;//set fps of render -1 is max		m_time = 0.0f;		text=       GameObject.Find ("text_fps")  .GetComponent
(); } // Update is called once per frame void Update () {   m_count++; if (m_count > 60) { text.text = "FPS:"+ ((int)(1 / delay)).ToString (); m_count=0; } delay = Time.realtimeSinceStartup - m_time; m_time = Time.realtimeSinceStartup; }}

转载于:https://my.oschina.net/kkkkkkkkkkkkk/blog/614194

你可能感兴趣的文章