You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/StompyRobot/SRDebugger/Scripts/UI/Controls/Profiler/ProfilerFPSLabel.cs

39 lines
851 B
C#

3 months ago
namespace SRDebugger.UI
{
using Services;
using SRF;
using UnityEngine;
using UnityEngine.UI;
public class ProfilerFPSLabel : SRMonoBehaviourEx
{
private float _nextUpdate;
protected override void Update()
{
base.Update();
if (Time.realtimeSinceStartup > _nextUpdate)
{
Refresh();
}
}
private void Refresh()
{
_text.text = "FPS: {0:0.00}".Fmt(1f/_profilerService.AverageFrameTime);
_nextUpdate = Time.realtimeSinceStartup + UpdateFrequency;
}
#pragma warning disable 649
[Import] private IProfilerService _profilerService;
public float UpdateFrequency = 1f;
[RequiredField] [SerializeField] private Text _text;
#pragma warning restore 649
}
}