Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to get the number batches/draw counts?

Discussion in 'General Graphics' started by ArachnidAnimal, May 13, 2015.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,727
    In the editor, the statistics window shows the # of batches while running the game. How do I get this value through a script? I searched the Unity scripting API and could not find anything.
    Thanks.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    There is, as you found, no API for that. It's only available in the editor.

    --Eric
     
    ArachnidAnimal likes this.
  3. vargonian

    vargonian

    Joined:
    Sep 3, 2011
    Posts:
    12
    Any update on this? Is there an API for this yet?
     
  4. vargonian

    vargonian

    Joined:
    Sep 3, 2011
    Posts:
    12
    Answering my question for those poor souls who run into this: Yes, in the UnityEditor namespace there is a class called UnityStats which has a "batches" property.
     
  5. Recart

    Recart

    Joined:
    Jun 4, 2017
    Posts:
    9
    Is there a way to know batch count at runtime in build?
     
    Biltekin and Lockthav like this.
  6. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    692
    any updates here?
     
  7. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    any updates here?
     
  8. liam_unity628

    liam_unity628

    Joined:
    Mar 10, 2020
    Posts:
    7
    If you do a debug build you can connect it to Unity and see the batch count through the profiler or the frame debugger.
     
    miracletechteam1 and MartinTilo like this.
  9. james_cg

    james_cg

    Joined:
    Nov 13, 2019
    Posts:
    15
    any updates here?

    it's 2020 now, why such a simple needs they donot provide?
     
  10. Lynxed

    Lynxed

    Joined:
    Dec 9, 2012
    Posts:
    121
    Let's add some visibility to this topic.
     
    alexeyzakharov likes this.
  11. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,159
    We've added ProfilerRecorder in 2020.2a that allows you to get the stats shown in the Rendering Module from code in players. More documentation and details on that are still pending and will come during the alpha/beta cycle.
     
  12. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    692
    Any chance this will be backported to 2019.4 LTS? @MartinTilo
     
  13. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,159
    No. To conserve the stability of LTS, only bugfixes and absolute necessities will be backported. This counts as a new feature and is too involved and risky to backport.
     
    VirtusH likes this.
  14. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    finally five long years
     
    astracat111 and Lorrak like this.
  15. Qazi_MinorBugs

    Qazi_MinorBugs

    Joined:
    Jul 7, 2021
    Posts:
    2
    Issue remains the same
    UnityEditor does'nt work at runtime
     
  16. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,159
    Yep, the UnityStats class remains unusable in players but we changed the underlying implementation for these stats and exposed them via the ProfilerRecorder API I mentioned above, which we added in the Unity namespace and the Player assembly in 2020.2. With that you can get the stats shown in the Rendering Profiler Module (which are the same as those in the stats view) by their name. Check out the Rendering Profiler Module documentation page for details and example code
     
    Lorrak, PutridEx and joshuacwilde like this.