FPS Counter
A lightweight FPS Counter. Tracks average, minimum and maximum frames per second of the application.
com.mygamedevtools.fps-counter Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/track/fps-counter.git README
FPS Counter
A package to measure the average, highest and lowest frames per second in any Unity Application.
Installation
OpenUPM
This package is available on the OpenUPM registry. Add the package via the openupm-cli:
openupm add com.mygamedevtools.fps-counter
Installing from Git (requires Git installed and added to the PATH)
- Open
Edit/Project Settings/Package Manager. - Click +.
- Select
Add package from git URL.... - Paste
com.mygamedevtools.fps-counterinto name. - Click
Add.
Usage
Add the component FPSCounter to any GameObject by manually dragging the script or via Add Component/Stats/FPS Counter.
Then, add a FPSDisplay component to the same GameObject the same way you just did with FPSCounter.
Now, you'll need to assign 3 TextMeshProUGUI objects in the FPSDisplay inspector to serve as output for the average, highest and lowest FPS counts respectively.
You can also configure the other settings to fit your needs:
- The
Color Gradientcan alter the label color based on the target FPS where the leftmost value is the closest FPS value to 0, and the rightmost value is the closest FPS value to theTarget Framerate. - The
Refresh Ratecontrols how often theFPSDisplayupdates its values. - The
Target Framerateis a guide to theColor Gradientproperty. It will be the reference for the value of 1 in the color gradient. - The
Max Tracked Fpscontrols what should be the maximum FPS to track.
Advanced Usage
The core FPS counter feature lies in the FPSBuffer.
It needs a bufferSize to be provided on creation, and then it will fill this buffer with FPS values to calculate the average, highest and lowest framerates.
You need to call UpdateBuffer every Unity Update to accurately calculate the FPS.
The FPSCounter component simply creates a FPSBuffer object on Awake with the provided Buffer Size in the inspector,
and runs FPSBuffer.UpdateBuffer on its Update.
You can use any other structure as an alternative to the FPSCounter or even integrate to your existing systems just by using a FPSBuffer object.
The FPSDisplay component reads from the FPSCounter component directly and outputs the average, highest and lowest fps.
You can also create another component to display the values either from the FPSCounter or from another system you created that uses a FPSBuffer object.
The FPSDisplay class was created with an array of strings with numbers up to 300, to avoid string allocation in runtime.
Don't hesitate to create issues for suggestions and bugs. Have fun!
Installs Over Time
Operating Systems
No data yet
Top Countries
No data yet
Git Versions
No data yet
Embed Install Badge
Add an install count badge to your README
[](https://www.pkglnk.dev/pkg/fps-counter)<a href="https://www.pkglnk.dev/pkg/fps-counter"><img src="https://www.pkglnk.dev/badge/fps-counter.svg?style=pkglnk" alt="pkglnk installs"></a>
No comments yet. Be the first!