poly and vertex counting at runtime

Hi all,

I'm trying to display at runtime (deployed app runtime) on the GUI the poly and vertex count visible on the camera and i came up with this:

using UnityEngine;
using System.Collections;

public class GFXStats : MonoBehaviour
{
    public GameObject[] allObjects;
    public float totalPoly;
    public int totalVertex;

    // Use this for initialization
    void Start()
    {
        allObjects = (GameObject[]) GameObject.FindObjectsOfType(typeof(GameObject));
    }

    void OnGUI()
    {
        string display = "polys: " + totalPoly.ToString() + " / vertex: " + totalVertex.ToString();
        Vector2 dimensao = GUI.skin.label.CalcSize(new GUIContent(display));
        GUI.Label(new Rect(Screen.width / 2 - dimensao.x / 2, Screen.height - 30, dimensao.x, 30), display);
    }

    // Update is called once per frame
    void Update()
    {
        float polyCount = 0;
        int vertCount = 0;
        foreach (GameObject obj in allObjects)
        {
            Renderer rend = obj.GetComponent<Renderer>();
            if (rend && rend.isVisible)
            {
                MeshFilter mf = obj.GetComponent<MeshFilter>();
                if (mf)
                {
                    polyCount += mf.mesh.triangles.Length/3;
                    vertCount += mf.mesh.vertexCount;
                }
            }
        }
        totalPoly = polyCount;
        totalVertex = vertCount;
    }
}

But the code is only counting the meshes totals. I was looking for the rendering totals (reflections, projectors, etc, increase those values) Any idea ?

Thanks in advance!

There is no way to extract these information in the player at least not without installing NVIDIA PerfHUD and checking them there

You're aware of the Rendering Statistics Window in the Game View, right? It does all this. It's not available in your built version though, but since you haven't specifically mentioned that you're aware of it, and you also haven't mentioned built vs. editor runtime, I've just got to check!

I’m also interrested by this answer, and to be more specific, by the number of polygons actually displayed by the graphical card (i.e. including frustum culling)

Blitz3D a directx7 basic metalanguage used in far 2000 that costed 100$ had total vertices and triangles count in 2 simple api call.
I can’t get why Unity doesn’t have such calls.

Here you can find an answer:
https://forum.unity.com/threads/get-tris-verts-in-code.172295/

Use
UnityEditor.UnityStats.triangles
UnityEditor.UnityStats.vertices
But it is available in Editor only.