简述
Unity5.0+的stats中,没法看到drawcall。虽说可以通过profiler查看,但多有不便。该脚本可以将信息显示到屏幕中
用法
将脚本复制到Unity中,挂载到任意一个GameObject中即可
详细代码
- 代码有从网络中借鉴
- 该信息只能在编辑器模式下有效
using UnityEngine;
using System.Collections;
public class UnityGameInfo : MonoBehaviour
{
#if UNITY_EDITOR
void OnGUI()
{
GUILayout.Space(50);
GUILayout.Label("Total DrawCall: " + UnityEditor.UnityStats.drawCalls, GUILayout.Width(500));
GUILayout.Label("Batch: " + UnityEditor.UnityStats.batches, GUILayout.Width(500));
GUILayout.Label("Static Batch DC: " + UnityEditor.UnityStats.staticBatchedDrawCalls, GUILayout.Width(500));
GUILayout.Label("Static Batch: " + UnityEditor.UnityStats.staticBatches, GUILayout.Width(500));
GUILayout.Label("DynamicBatch DC: " + UnityEditor.UnityStats.dynamicBatchedDrawCalls, GUILayout.Width(500));
GUILayout.Label("DynamicBatch: " + UnityEditor.UnityStats.dynamicBatches, GUILayout.Width(500));
GUILayout.Label("Tri: " + UnityEditor.UnityStats.triangles, GUILayout.Width(500));
GUILayout.Label("Ver: " + UnityEditor.UnityStats.vertices, GUILayout.Width(500));
}
#endif
}