Catlike Coding
Unity Code Documentation
Public Attributes | Properties | List of all members
CatlikeCoding.Utilities.FrameRateCounter Class Reference

A frame rate counter. More...

Inherits MonoBehaviour.

Public Attributes

float averageFPS
 Average frames per second. More...
 
int frameRange = 10
 Frame range to use. More...
 
float maxFPS
 Maximum frames per second. More...
 
float minFPS
 Minimum frames per second. More...
 
bool useDeltaTime = true
 Whether the counter uses Time.deltaTime to determine the frame rate. More...
 

Properties

string AverageString [get]
 Average frames per second as a 00-99 string. More...
 
string MaxString [get]
 Maximum frames per second as a 00-99 string. More...
 
string MinString [get]
 Minimum frames per second as a 00-99 string. More...
 

Detailed Description

A frame rate counter.

It keeps track of the maximum, average, and minimum frames per seconds for a customizable range of frames. The higher the range, the more stable the values will be.

The counter can be made independent of Time.timeScale.

You can access string representations of the frame rates, in which case you get floored values in the range 00-99. These string representations are cached, resulting in zero memory allocation after the first request. This is faster and more memory friendly than converting the floats to strings each time you want to show them.

See the product page for an overview.

Member Data Documentation

float CatlikeCoding.Utilities.FrameRateCounter.averageFPS

Average frames per second.

int CatlikeCoding.Utilities.FrameRateCounter.frameRange = 10

Frame range to use.

Resets to 1 on update if set to a lower value.

float CatlikeCoding.Utilities.FrameRateCounter.maxFPS

Maximum frames per second.

float CatlikeCoding.Utilities.FrameRateCounter.minFPS

Minimum frames per second.

bool CatlikeCoding.Utilities.FrameRateCounter.useDeltaTime = true

Whether the counter uses Time.deltaTime to determine the frame rate.

Setting this to false makes it use Time.realtimeSinceStartup instead. This method can be less precise, but is more practical when Time.timeScale isn't always 1.

Property Documentation

string CatlikeCoding.Utilities.FrameRateCounter.AverageString
get

Average frames per second as a 00-99 string.

The string is cached.

string CatlikeCoding.Utilities.FrameRateCounter.MaxString
get

Maximum frames per second as a 00-99 string.

The string is cached.

string CatlikeCoding.Utilities.FrameRateCounter.MinString
get

Minimum frames per second as a 00-99 string.

The string is cached.