https://github.com/mygamedevtools/fps-counter
A lightweight FPS Counter for Games and Apps made with Unity.
https://github.com/mygamedevtools/fps-counter
diagnostics editor package stats tools unity unity-editor unity-package unity-plugin unity3d unity3d-plugin unityeditor upm upm-package
Last synced: 2 days ago
JSON representation
A lightweight FPS Counter for Games and Apps made with Unity.
- Host: GitHub
- URL: https://github.com/mygamedevtools/fps-counter
- Owner: mygamedevtools
- License: mit
- Created: 2022-09-14T00:44:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-25T23:29:23.000Z (almost 3 years ago)
- Last Synced: 2025-04-07T20:41:18.298Z (6 months ago)
- Topics: diagnostics, editor, package, stats, tools, unity, unity-editor, unity-package, unity-plugin, unity3d, unity3d-plugin, unityeditor, upm, upm-package
- Language: C#
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://openupm.com/packages/com.mygamedevtools.fps-counter/)

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](https://openupm.com/packages/com.mygamedevtools.fps-counter) registry. Add the package via the [openupm-cli](https://github.com/openupm/openupm-cli):
```
openupm add com.mygamedevtools.fps-counter
```### [Installing from Git](https://docs.unity3d.com/Manual/upm-ui-giturl.html) _(requires [Git](https://git-scm.com/) installed and added to the PATH)_
1. Open `Edit/Project Settings/Package Manager`.
2. Click +.
3. Select `Add package from git URL...`.
4. Paste `com.mygamedevtools.fps-counter` into name.
5. 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 Gradient` can 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 the `Target Framerate`.
- The `Refresh Rate` controls how often the `FPSDisplay` updates its values.
- The `Target Framerate` is a guide to the `Color Gradient` property. It will be the reference for the value of 1 in the color gradient.
- The `Max Tracked Fps` controls 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](https://github.com/mygamedevtools/fps-counter/issues) for suggestions and bugs. Have fun!