Display FPS on screen in Unity

Daniel Kirwan
1 min readSep 20, 2024

--

It is really simple to display the FPS of your game whilst it is running.

In my game, I display 3 FPS text boxes so that I can monitor the current FPS, the best FPS and the lowest FPS.

So create some text component refs in your script and follow along below.

[SerializeField] private TextMeshProUGUI _fpsText;
[SerializeField] private TextMeshProUGUI _bestfpsText;
[SerializeField] private TextMeshProUGUI _lowestfpsText;
private float updateInterval = 1.0f;
private int _bestFps;
private int _lowestFps;

private float _currentFPS;

private void Start()
{
_fpsText.text = "FPS: 0";
_lowestFps = 100;
}

private void Update()
{
_currentFPS = 1f / Time.deltaTime;
UpdateFPS();
}

private void UpdateFPS()
{
if (_currentFPS >= _bestFps)
{
_bestFps = (int)_currentFPS;
_bestfpsText.text = $"Best FPS: {_bestFps}";
}

if (_lowestFps >= _currentFPS)
{
_lowestFps = (int)_currentFPS;
_lowestfpsText.text = $"Low FPS: {_lowestFps}";
}

_fpsText.text = "Curr FPS: " + Mathf.RoundToInt(_currentFPS);
}

Above is the whole script and updates all the text with the FPS.

This is a great way to monitor how your game is performing in certain scenes.

That’s it for today. Check out my other articles on game development in Unity.

--

--