topical media & game development

talk show tell print

lib-unity-demo-sewer-Assets--Scripts-FPS.js / js



  # pragma strict
  
  var fps : float = 0.00;
  
  var fpses = Array();
  
  function Update ()
  {
          fps = 1 / Time.smoothDeltaTime;
          fpses.Add(fps);
  }
  
  function Start ()
  {
          while (true)        
          {
                  var nfps : float = 0.00;
                  for(var f : float in fpses)
                  {
                          nfps += f / fpses.length;
                  }        
                  guiText.text = "FPS: " + Mathf.Round(nfps);
                  fpses.length = 0;
                  yield WaitForSeconds(0.3);
          }
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.