- Home /
Statistics windows on a mobile device
Hi, I would like to see information like statistics windows (http://docs.unity3d.com/Documentation/Manual/RenderingStatistics.html) on a mobile device.
Is it possible? If not, is there an alternative to it?
I'm having the same question and am still wondering for a better solution. Have you find any solution to this yet, grayger?
Answer by SAP · Dec 25, 2013 at 11:20 AM
You can calculate the fps and draw calls. Code below will show the draw calls and Fps if attached to a camera or any game object.
Please note that , you should extend draw calls function in script below, for counting GUI which exits on Screen.
using UnityEngine; using System.Collections;
public class ShowInfo : MonoBehaviour {
public float updateInterval = 0.5F;
private float accum = 0; // FPS accumulated over the interval
private int frames = 0; // Frames drawn over the interval
private float timeleft; // Left time for current interval
private string fpsText;
private GameObject[] AllObjects;
private int DrawCalls;
void CalculateFPS()
{
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)
float fps = accum / frames;
string format = System.String.Format("{0:F2} FPS", fps);
fpsText = format;
timeleft = updateInterval;
accum = 0.0F;
frames = 0;
}
}
void Draw_DrawCalls()
{
foreach (GameObject g in AllObjects)
{
if (g.renderer && g.renderer.isVisible)
{
DrawCalls++;
}
}
}
void Start () {
timeleft = updateInterval;
AllObjects = (GameObject[])GameObject.FindObjectsOfType(typeof(GameObject)) ;
}
// Update is called once per frame
void Update () {
CalculateFPS();
Draw_DrawCalls();
}
void OnGUI() {
GUI.Label(new Rect(0.0f, 0.0f, 100.0f, 25.0f), fpsText);
GUI.Label(new Rect(0.0f, 50.0f, 200.0f, 25.0f), "Total Draw Calls : "+ DrawCalls.ToString());
}
}
Hope this helps...
That's not a very accurate measure of draw-calls, especially when batching is enabled and the fact that the OnGUI
function will add draw calls by itself. It also won't check for objects added after Start
was called. Problems will also occur with a timeScale
of 0
. It should also check for disabled renderers and multiply the draw calls by the number of active cameras for more accurate results.
On that note, the number of draw calls from Editor to $$anonymous$$obile shouldn't be different :)
I'm not too sure about the accuracy, but I kind of expect that there should be some easier way out to displaying this rendering statistics just like what Unity has in the Game view. Any answer to this problem yet?
Your answer

Follow this Question
Related Questions
Creating Unity Statistics Plugin 0 Answers
Disabled Analytic and HW Statistic but Unity still use cdp.cloud.unity3d.com 1 Answer
Showing Full FPS 1 Answer
How to make a Linediagram 1 Answer