How to round fps variable.

How to round fps amount correct?

I think i should add f somewhere in Mathf.Round(fps);
But i don’t know where.

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class fpsCounter : MonoBehaviour
{

    public TMP_Text fpsCounter_txt;

    void Update(){
        float fps = 1 / Time.unscaledDeltaTime;
        Mathf.Round(fps);
        fpsCounter_txt.text = "fps: " + fps;
    }
}

Thanks in advance.

You need to capture the result of the Round operation somewhere! Also you’ll want it as an int, so use RoundToInt:

    void Update(){
        float fps = 1 / Time.unscaledDeltaTime;
        int roundedFps = Mathf.RoundToInt(fps);
        fpsCounter_txt.text = "fps: " + roundedFps;
    }
1 Like

thanks