usingUnityEngine;usingSystem.Collections;//HAY QUE APLICAR EL SCRIPT EN LA CAMARA publicclassFPSDisplay:MonoBehaviour{floatdeltaTime=0.0f;//Al actualizar cada FramevoidUpdate(){deltaTime+=(Time.deltaTime-deltaTime)*0.1f;}//Al mostrar el GUIvoidOnGUI(){intw=Screen.width,h=Screen.height;GUIStylestyle=newGUIStyle();Rectrect=newRect(0,0,w,h*2/100);style.alignment=TextAnchor.UpperLeft;style.fontSize=h*2/100;style.normal.textColor=newColor(0.0f,0.0f,0.5f,1.0f);floatmsec=deltaTime*1000.0f;floatfps=1.0f/deltaTime;stringtext=string.Format("{0:0.0} ms ({1:0.} fps)",msec,fps);GUI.Label(rect,text,style);}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.