40 lines
1.6 KiB
C#
40 lines
1.6 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
namespace BITKit
|
||
|
{
|
||
|
public class ShowProfiler : BITBehavior
|
||
|
{
|
||
|
[Header(Constant.Header.Settings)]
|
||
|
[SubclassSelector, SerializeReference] public References pingAddress;
|
||
|
[Header(Constant.Header.Output)]
|
||
|
[SerializeField,SerializeReference,SubclassSelector] private IProvider fpsOutput;
|
||
|
[SerializeField,SerializeReference,SubclassSelector] private IProvider pingOutput;
|
||
|
[SerializeField,SerializeReference,SubclassSelector] private IProvider resolutionOutput;
|
||
|
[SerializeField,SerializeReference,SubclassSelector] private IProvider frameRateOutput;
|
||
|
private readonly DeltaTimer timer = new();
|
||
|
private Ping ping;
|
||
|
[Header(Constant.Header.InternalVariables)]
|
||
|
private int frameRate;
|
||
|
private void Update()
|
||
|
{
|
||
|
timer.Update();
|
||
|
frameRate = timer;
|
||
|
fpsOutput.Set((string)timer);
|
||
|
if (pingOutput is not null && (ping is null || ping.isDone))
|
||
|
{
|
||
|
if (ping is not null && ping.isDone)
|
||
|
{
|
||
|
pingOutput.Set(ping.time.ToString());
|
||
|
}
|
||
|
ping = new Ping(pingAddress);
|
||
|
}
|
||
|
resolutionOutput?.Set(Screen.currentResolution.ToString());
|
||
|
frameRateOutput?.Set(Application.targetFrameRate is -1 or 0 ? "Unlimited" : Application.targetFrameRate.ToString());
|
||
|
}
|
||
|
public override string GetName()
|
||
|
{
|
||
|
return nameof(ShowProfiler);
|
||
|
}
|
||
|
}
|
||
|
}
|