纳金网
标题:
Unity3D中显示运行帧数的代码
[打印本页]
作者:
狂风大尉
时间:
2014-6-26 20:04
标题:
Unity3D中显示运行帧数的代码
//创建一个js脚本,然后写好后加入到GUItext即可
var updateInterval = 0.5;
private var accum = 0.0; // FPS accumulated over the interval
private var frames = 0; // Frames drawn over the interval
private var timeleft : float; // Left time for current interval
function Start()
{
if( !guiText )
{
print ("FramesPerSecond needs a GUIText component!");
enabled = false;
return;
}
timeleft = updateInterval;
}
function Update()
{
timeleft -= Time.deltaTime;
accum += Time.timeScale/Time.deltaTime;
++frames;
// Interval ended - update GUI text and start new interval
if( timeleft <= 0.0 )
{
// display two fractional digits (f2 format)
guiText.text = "" + (accum/frames).ToString("f2");
timeleft = updateInterval;
accum = 0.0;
frames = 0;
}
}
复制代码
来源:http://www.unity3d8.com/
作者:
hyui
时间:
2014-6-26 21:22
感谢分享这个!
作者:
HIDEOKOJIMA
时间:
2014-6-26 22:40
感谢分享这个!
作者:
wucnj
时间:
2014-6-27 13:20
感谢分享!!!
作者:
wa5145416
时间:
2014-8-15 18:10
挺厉害的。。
欢迎光临 纳金网 (http://wwww.narkii.com/club/)
Powered by Discuz! X2.5