微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

unity中显示帧数c#代码

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);

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐