Search Unity

Is my frames per second counter correct?

Discussion in 'Scripting' started by GamersHeaven, Mar 3, 2010.

  1. GamersHeaven

    GamersHeaven

    Joined:
    Feb 15, 2010
    Posts:
    88
    Iam pretty bad at scripting with unity :oops:
    But i neaded an true fps counter to se in game framedrops and such.
    I have used an delay counter so that you have time to see the fps, as they flicker to fast without it :D
    Is this correctly done?
    Simply wondering as the counter goes from 49 - 110 fps constantly.
    Dropping down to 49 seams pretty bad with so little going on on the screen?
    The built in editors fps counter in the stats clocks around 600-900 fps and with an max of 24 drawcalls.

    Code (csharp):
    1.  
    2. var show = false;
    3. var delay = 0.2;
    4. private var nextdelay = Time.time + delay;
    5. private var oldfps = 0.0;
    6. function Update () {
    7.     if (show){
    8.       if (Time.timeScale != 0.0 Time.time > nextdelay){
    9.       nextdelay = Time.time + delay;
    10.       var fps : int = 1.0 / Time.deltaTime;
    11.       guiText.text = fps.ToString();
    12.       oldfps=fps;
    13.       }
    14. guiText.text = oldfps.ToString();      
    15.    }
    16. }
    17.  
    18. @script RequireComponent(GUIText)
    19.  
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  3. GamersHeaven

    GamersHeaven

    Joined:
    Feb 15, 2010
    Posts:
    88
    Thanks eric :oops:
    Iam always forgetting the wiki :oops:
    I whas pretty far of with my counter :oops:
    Could you help me out on some specs for wiiware and iphone development pages,where you can find info on various performance and wath shaders you can use etc.
    Iam hoping to be able to do an game with unity that i maybe can get to be published as wiiware :D