Space Plunder
Loading...
Searching...
No Matches
UFramesPerSecondWidget Class Reference

#include <FramesPerSecondWidget.h>

Inheritance diagram for UFramesPerSecondWidget:

Protected Member Functions

virtual bool Initialize () override
 
virtual void NativeConstruct () override
 

Protected Attributes

class UTextBlock * FramesTextBlock
 
float UpdateSpeed = 1.0f
 

Private Member Functions

void UpdateFPS () const
 

Private Attributes

FTimerHandle UpdateSpeedTimer
 

Member Function Documentation

◆ Initialize()

bool UFramesPerSecondWidget::Initialize ( )
overrideprotectedvirtual
11{
12 const bool Success = Super::Initialize();
13 if(!Success) return false;
14 if (!ensure(FramesTextBlock != nullptr)) return false;
15 return true;
16}
class UTextBlock * FramesTextBlock
Definition FramesPerSecondWidget.h:24

◆ NativeConstruct()

void UFramesPerSecondWidget::NativeConstruct ( )
overrideprotectedvirtual
19{
20 Super::NativeConstruct();
21 if(GetWorld() != nullptr && GetOwningPlayer() != nullptr)
22 {
23 GetWorld()->GetTimerManager().SetTimer(UpdateSpeedTimer, this, &UFramesPerSecondWidget::UpdateFPS, UpdateSpeed, true, 0.0f);
24 }
25}
float UpdateSpeed
Definition FramesPerSecondWidget.h:26
FTimerHandle UpdateSpeedTimer
Definition FramesPerSecondWidget.h:30
void UpdateFPS() const
Definition FramesPerSecondWidget.cpp:27

◆ UpdateFPS()

void UFramesPerSecondWidget::UpdateFPS ( ) const
private
28{
29 const float WorldTime = UGameplayStatics::GetWorldDeltaSeconds(GetOwningPlayer());
30 const int32 FramesPerSecond = UKismetMathLibrary::FTrunc((1.0f / WorldTime));
31 FramesTextBlock->SetText(FText::FromString(FString::FromInt(FramesPerSecond)));
32}

Member Data Documentation

◆ FramesTextBlock

class UTextBlock* UFramesPerSecondWidget::FramesTextBlock
protected

◆ UpdateSpeed

float UFramesPerSecondWidget::UpdateSpeed = 1.0f
protected

◆ UpdateSpeedTimer

FTimerHandle UFramesPerSecondWidget::UpdateSpeedTimer
private

The documentation for this class was generated from the following files: