Accessing number of drawcalls from script

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Javascript - DrawCalls.js)
Line 1: Line 1:
 
By: Alex Schwartz (GTJuggler)
 
By: Alex Schwartz (GTJuggler)
  
''IMPORTANT:''' When running in the editor, scene view cameras will be included in the draw call count!
+
'''IMPORTANT''' - When running in the editor, scene view cameras will be included in the draw call count!
  
 
== Javascript - DrawCalls.js ==
 
== Javascript - DrawCalls.js ==

Revision as of 01:30, 6 March 2010

By: Alex Schwartz (GTJuggler)

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

Javascript - DrawCalls.js

<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