33 lines
882 B
C#
33 lines
882 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
{
|
|
public class FpsController : MonoBehaviour
|
|
{
|
|
public float showTime = 1f;
|
|
public Text tvFpsInfo;
|
|
private int count = 0;
|
|
private float deltaTime = 0f;
|
|
// Update is called once per frame
|
|
private void Awake()
|
|
{
|
|
tvFpsInfo = GetComponent<Text>();
|
|
}
|
|
private void Update()
|
|
{
|
|
count++;
|
|
deltaTime += Time.deltaTime;
|
|
if (deltaTime >= showTime)
|
|
{
|
|
float fps = count / deltaTime;
|
|
//float milliSecond = deltaTime * 1000 / count;
|
|
string strFpsInfo = string.Format("{0:0.}FPS", fps);
|
|
tvFpsInfo.text = strFpsInfo;
|
|
count = 0;
|
|
deltaTime = 0f;
|
|
}
|
|
}
|
|
}
|
|
}
|