【发布时间】:2015-08-29 07:45:00
【问题描述】:
我很长一段时间以来在手机上的流畅相机(平台游戏)上遇到问题,但我报告说当我的 fps 不低于 60 时我的游戏运行良好。我注意到我的 fps 很好我触摸屏幕,但是当我不这样做时,fps 会下降到大约 58、59,之后我的相机不能顺利地跟随我的播放器。为了测试,我只用 FPSCounter 脚本创建了新场景,效果是一样的。有人可以帮我吗?我认为这是引擎设置的原因,但我无法处理它。强调文本
//---------------------------------------------
// VARIABLES
//---------------------------------------------
private float deltaTime = 0.0f;
//---------------------------------------------
// METHODS FROM SUPERCLASS
//---------------------------------------------
void Update()
{
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
}
void OnGUI()
{
GUIStyle style = new GUIStyle();
float x = Screen.width - 110;
float fps = 1.0f / deltaTime;
Rect rect = new Rect(x, 90, 100, 50);
style.fontSize = 18;
style.normal.textColor = getColor(fps);
string text = string.Format("{0:0,0.0000 FPS}",fps);
GUI.Label(rect, text, style);
}
//---------------------------------------------
// CLASS LOGIC
//---------------------------------------------
private Color getColor(float fps)
{
if (fps >= 60)
{
return Color.yellow;
}
return Color.red;
}
【问题讨论】:
标签: android unity3d touch frame-rate