Unity3D Tutorial FPS Counter
Easter video series !
THIS IS C# script: GOOD 4 2D GAMES AND 3D GAMES !
--------------------------------------------------------------------------------------
DIRECT DOWNLOAD HERE
THIS IS BACKUP IN TEXT FORM TUTORIAL FpsCounter
1. Create New C# and name it : FpsCounter
2. Copy & Past this text and save C#
---------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
public class FpsCounter : MonoBehaviour
{
private const float FPS_UPDATE_INTERVAL = 0.5f;
private float fpsAccum = 0;
private int fpsFrames = 0;
private float fpsTimeLeft = FPS_UPDATE_INTERVAL;
private float fps = 0;
void Update()
{
fpsTimeLeft -= Time.deltaTime;
fpsAccum += Time.timeScale / Time.deltaTime;
fpsFrames++;
if (fpsTimeLeft <= 0)
{
fps = fpsAccum / fpsFrames;
fpsTimeLeft = FPS_UPDATE_INTERVAL;
fpsAccum = 0;
fpsFrames = 0;
}
}
void OnGUI()
{
GUILayout.BeginArea(new Rect(5, 5, 500, 500));
GUILayout.Label("FPS: " + fps.ToString("f1"));
GUILayout.EndArea();
}
}
---------------------------------------------------------------------------------
0 comments:
Post a Comment