Accessing number of drawcalls from script

By: Alex Schwartz (GTJuggler)

Note - When running in the editor, scene view cameras will be included in the draw call count! Also, if you instantiate new objects at runtime, this script will not take those into account, so you should deal with that case manually.

FYI - This is NOT producing anything remotely like a "number of draw calls". It will tell you how many renderers will render something in a given frame, more or less. Any given object may produce 0..N draw calls depending on the number/kind of lights hitting it, shadowcasting settings, number of materials / sub-meshes, and so forth. On top of that, some objects such as terrains can vary considerably in the number of draw calls. And that doesn't address things like image effects, GUIs (both GUILayer-based and UnityGUI).