#pragma strictvar speed:float = 100;var m_lastupdateshowtime:float = 0f;//The last time the frame rate was updated; var m_updateshowdeltatime:float =0.01f;//update frame rate interval; var m_frameupdate:int = 0;//Frame number var m_fps:float = 0;function Awake () {application.targetframerate = 100;} function Start () { m_lastupdateshowtime=time.realtimesincestartup; } function Update () {var x:float = Input.getaxis ("horizontal") * time.deltatime * Speed;var z:float = Input.getaxis ("vertic Al ") *time.deltatime * speed;transform. Translate (x,0,z); m_frameupdate++; if (time.realtimesincestartup-m_lastupdateshowtime>=m_updateshowdeltatime) { m_fps=m_frameupdate/( Time.realtimesincestartup-m_lastupdateshowtime); m_frameupdate=0; M_lastupdateshowtime=time.realtimesincestartup; } } function Ongui () { GUI. Label (New Rect (screen.width/2,0,200,100), "FPS:" +m_fps); }
Unity creates the first JavaScript script that moves the object with the keyboard and the frame rate display on top of the attached object