Search Unity

Accessing Draw Calls, Tris, VRAM usage via Code

Discussion in 'Editor & General Support' started by agusgriego, Sep 3, 2008.

  1. agusgriego

    agusgriego

    Joined:
    Sep 3, 2008
    Posts:
    12
    hi Everyone!

    We are doing a tool to analyze the performance of a certain Scene.

    We run a camera throughout the scene and save data about the process. We want to access draw calls, tris, and the rest of the data you get in the Stats window in order to record it per frame and analyze it later.

    Is this possible? I couldn't find any class providing this data.

    Thanks!
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    In editor code, you can access it via undocumented class UnityStats (use Reflector or some other tool on UnityEditor.dll to find class and it's methods). However, it is an undocumented class, so it could go away or be refactored anytime without a notice. So be warned :)
     
  3. Lucas Meijer_old

    Lucas Meijer_old

    Joined:
    Apr 5, 2008
    Posts:
    436
    Would it be possible for unity to in turn use reflection / analysis on our code to check if anybody happens to use anything that's marked as undocumented?

    I guess we could write that ourselves, if the classes/methods we shouldn't be using would be tagged with an attribute. (or have everything we can use be tagged, but that's more work I guess).

    Bye, Lucas
     
  4. agusgriego

    agusgriego

    Joined:
    Sep 3, 2008
    Posts:
    12
    Thanks guys!! you rock!
     
  5. agusgriego

    agusgriego

    Joined:
    Sep 3, 2008
    Posts:
    12
    I have another question about this.

    First of all, to everybody that tries to do this, the drawCalls data, the triangles and meshes, etc. are only available in the OnPostRender function. Before that they are zero!

    Is there any way to access the values of these options in code? These are the options you set in the Quality settings. The QualitySettings class only has pixelLightCount, shadowCascades,shadowDistance and softVegetation:
    Shadows
    Shadow Resolution
    Blend Weights
    Texture Quality
    Anisotropic Textures
    Anti Aliasing
    Sync To VBL

    Thanks!