Accessing number of drawcalls from script

From Unify Community Wiki
Revision as of 01:29, 6 March 2010 by Gtjuggler (Talk | contribs)

Jump to: navigation, search

Javascript - DrawCalls.js

By: Alex Schwartz (GTJuggler)

VERY IMPORTANT: When running in the editor, scene view cameras will be included in the draw call count!

<javascript>var drawcalls : int = 0; var allObjects : GameObject[];

function Start(){ allObjects = FindObjectsOfType (GameObject); }

function Update(){ for(var obj : GameObject in allObjects){ var rend : Renderer = obj.GetComponent(Renderer); if(rend && rend.isVisible){ drawcalls++; } }

//print drawcalls Debug.Log(drawcalls);

//reset drawcalls every update drawcalls = 0;

//do some math to find average drawcall count here }</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox