Class FpsToText
Displays the current framerate in a Text component with optional color coding. Supports both instantaneous and averaged FPS measurements.
Namespace: NWH.Common.Demo
Assembly: NWH.DWP2.dll
Syntax
[RequireComponent(typeof(Text))]
public class FpsToText : MonoBehaviour
Fields
| Edit this page View Sourcebad
Text color when framerate is below badBelow threshold.
Declaration
public Color bad
Field Value
| Type | Description |
|---|---|
| Color |
badBelow
FPS threshold below which the color changes to bad (red).
Declaration
public int badBelow
Field Value
| Type | Description |
|---|---|
| int |
forceIntResult
Round FPS to nearest integer for cleaner display.
Declaration
public bool forceIntResult
Field Value
| Type | Description |
|---|---|
| bool |
good
Text color when framerate is above okayBelow threshold.
Declaration
public Color good
Field Value
| Type | Description |
|---|---|
| Color |
groupSampling
Use averaging over multiple samples instead of single frame measurement.
Declaration
public bool groupSampling
Field Value
| Type | Description |
|---|---|
| bool |
okay
Text color when framerate is between badBelow and okayBelow.
Declaration
public Color okay
Field Value
| Type | Description |
|---|---|
| Color |
okayBelow
FPS threshold below which the color changes to okay (yellow).
Declaration
public int okayBelow
Field Value
| Type | Description |
|---|---|
| int |
sampleSize
Number of samples to average when groupSampling is enabled.
Declaration
public int sampleSize
Field Value
| Type | Description |
|---|---|
| int |
smoothed
Use Time.smoothDeltaTime instead of Time.deltaTime for calculations.
Declaration
public bool smoothed
Field Value
| Type | Description |
|---|---|
| bool |
updateTextEvery
Update text display every N frames. 1 = every frame.
Declaration
public int updateTextEvery
Field Value
| Type | Description |
|---|---|
| int |
useColors
Enable color coding based on framerate thresholds.
Declaration
public bool useColors
Field Value
| Type | Description |
|---|---|
| bool |
useSystemTick
Use Environment.TickCount instead of Time.deltaTime for calculations.
Declaration
public bool useSystemTick
Field Value
| Type | Description |
|---|---|
| bool |
Methods
| Edit this page View SourceGetSystemFramerate()
Declaration
protected virtual int GetSystemFramerate()
Returns
| Type | Description |
|---|---|
| int |
Group()
Declaration
protected virtual void Group()
Reset()
Declaration
protected virtual void Reset()
SingleFrame()
Declaration
protected virtual void SingleFrame()
Start()
Declaration
protected virtual void Start()
Update()
Declaration
protected virtual void Update()