我刚刚创建了一个新项目并构建了一个带有一些精灵的开场场景,相同的场景在统一 4.7 中以 60FPS 运行,但我无法在统一 5.6 中获得它。我只有一个简单的脚本(fps 计数器)、一个简单的动画(1 个叶子)、一个场景中的 15 个精灵和带有文本的画布,只有 5 个绘制调用。我什至手动优化了精灵网格,因此它们的过度绘制更少。它发生在android和PC上。
使用我的 fps 脚本和内部分析器:
Unity4.7 > PC 450fps | Android 60fps
Unity5.6 > PC 110fps | 安卓35-50fps
这是 FPS 脚本
using UnityEngine;
using UnityEngine.UI;
public class FrameCounter : MonoBehaviour
{
public float refreshInterval;
private Text label;
private float delta;
private float frames;
private float res;
// Use this for initialization
void Start ()
{
label = GetComponent<Text>();
delta = 0;
frames = 0;
}
// Update is called once per frame
void Update ()
{
frames++;
delta += Time.deltaTime;
if (delta > refreshInterval)
{
res = delta / frames;
label.text = 1f / res + " (" + 1000f * res + "ms)";
delta = 0;
frames = 0;
}
}
}
经过一些设置调整:关闭 32 位缓冲区,从图形 API 列表中删除 OpenGLES2,将质量设置设置为最快,我得到了一些性能提升,但还不够。无法获得 60FPS :( 这是调整后的内部分析器结果:
02-21 04:58:07.719 30216 30291 D Unity : Android Unity internal profiler stats:
02-21 04:58:07.719 30216 30291 D Unity : cpu-player> min: 12.7 max: 36.4 avg: 20.5
02-21 04:58:07.719 30216 30291 D Unity : cpu-ogles-drv> min: 0.0 max: 0.0 avg: 0.0
02-21 04:58:07.719 30216 30291 D Unity : gpu> min: 0.0 max: 0.0 avg: 0.0
02-21 04:58:07.720 30216 30291 D Unity : cpu-present> min: -20.0 max: 1.4 avg: -1.6
02-21 04:58:07.720 30216 30291 D Unity : frametime> min: 13.0 max: 34.6 avg: 18.9
02-21 04:58:07.720 30216 30291 D Unity : batches> min: 5 max: 5 avg: 5
02-21 04:58:07.720 30216 30291 D Unity : draw calls> min: 5 max: 5 avg: 5
02-21 04:58:07.720 30216 30291 D Unity : tris> min: 274 max: 274 avg: 274
02-21 04:58:07.720 30216 30291 D Unity : verts> min: 348 max: 348 avg: 348
02-21 04:58:07.720 30216 30291 D Unity : dynamic batching> batched draw calls: 13 batches: 1 tris: 226 verts: 252
02-21 04:58:07.720 30216 30291 D Unity : static batching> batched draw calls: 0 batches: 0 tris: 0 verts: 0
02-21 04:58:07.720 30216 30291 D Unity : player-detail> physx: 0.0 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.3 render: -0.3 fixed-update-count: 0 .. 0
02-21 04:58:07.720 30216 30291 D Unity : managed-scripts> update: 0.0 fixedUpdate: 0.0 coroutines: 0.0
02-21 04:58:07.720 30216 30291 D Unity : managed-memory> used heap: 372736 allocated heap: 512000, max number of collections: 0 collection total duration: 0.0
02-21 04:58:07.720 30216 30291 D Unity : ----------------------------------------
我做错了什么吗?