I want to add a Stats menu to my game, including an FPS counter.
I have searched the Unity Documentation, but don’t know how to implement that into my code.
If anyone can help me understand, I would very much appreciate it.
Thanks!
I want to add a Stats menu to my game, including an FPS counter.
I have searched the Unity Documentation, but don’t know how to implement that into my code.
If anyone can help me understand, I would very much appreciate it.
Thanks!
Thank you for the video, but do you know how to read the Unity Documentation and implement it?
I cant find anything on that, no idea if thats the right docs.
Maybe someone else knows then.
From what i can see, people do it like this;
[SerializeField] int FPS;
float frameRateFloat;
void Update()
{
frameRateFloat = 1.0f / Time.deltaTime;
FPS = (int)frameRateFloat;
}
you can count the frames in update and every second display counted frames on ui and start count again.
int frames = 0;
float period = 1f;
float elapsed =0f;
void Update(){
frames ++;
elapsed += Time.deltaTime;
if(elapsed > period)
{
elapsed =0;
frames = 0;
}
}
Okay, thank you!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.