FPS Counter
Introduction
A widget used to display the current framerate
Dependencies
The FpsCounter
relies on other components of this plugin to work:
- Logger: Used to log useful information to help you debug any issues you might experience
- Game Instance: Used to monitor for input device changes and handle saving/loading game data
Required Widgets
There is already a FpsCounter_Implementation
that you can use in your projects. But if you create your own instance of this widget, you need to add the following before you can compile:
Name | Description | Type |
---|---|---|
SimpleViewContainer | Container for the simple view | UCanvasPanel* |
DetailedViewContainer | Container for the detailed view | UCanvasPanel* |
FramerateSimpleText | The text block used to display the framerate in the simple view | UTextBlock* |
FramerateText | The text block used to display the framerate | UTextBlock* |
MinText | The text block used to display the min framerate | UTextBlock* |
MaxText | The text block used to display the max framerate | UTextBlock* |
AverageText | The text block used to display the average framerate | UTextBlock* |
API Reference
Properties
Property | Description | Type | Default Value |
---|---|---|---|
UpdateDelay | The delay in seconds between each update | float | 0.125f |
MeasureTime | The amount of seconds to measure the FPS before removing old measurements | int | 120 |
HighFramerate | A framerate that is considered high and will use the high color | int | 60 |
MediumFramerate | A framerate that is considered medium and will use the medium color | int | 30 |
HighColor | The color used to display high framerates | FLinearColor | FLinearColor::Green |
MediumColor | The color used to display medium framerates | FLinearColor | FLinearColor::Yellow |
LowColor | The color used to display low framerates | FLinearColor | FLinearColor::Red |
Functions
Name | Description | Params | Return |
---|---|---|---|
UpdateVisibility | Update the visibility of the widget | IsVisible (bool) Is the widget visible? |
|
LoadSettings | Load and apply the FPS counter settings |
Blueprint Usage
You can use the FpsCounter
using Blueprints by adding one of the following nodes:
- Ultimate Starter Kit > UI > Update Visibility
- Ultimate Starter Kit > UI > Load Settings
C++ Usage
Before you can use the plugin, you first need to enable the plugin in your Build.cs
file:
PublicDependencyModuleNames.Add("USK");
The FpsCounter
can now be used in any of your C++ files:
#include "USK/Widgets/FpsCounter.h"
void ATestActor::Test()
{
// FpsCounter is a pointer to the UFpsCounter
FpsCounter->UpdateVisibility(IsVisible);
FpsCounter->LoadSettings();
}