Unity3D Tutorial FPS Counter

Advertisemen

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();
}
}








 ----------------------------------------­­­­­------------------------------------­-­-­-­-­-

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D