1
This commit is contained in:
45
Unity/Scripts/Components/ShowProfiler.cs
Normal file
45
Unity/Scripts/Components/ShowProfiler.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ShowProfiler : BITBehavior, IDiagnostics
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SubclassSelector, SerializeReference] public References pingAddress;
|
||||
[Header(Constant.Header.Output)]
|
||||
public Provider fpsOutput;
|
||||
public Provider pingOutput;
|
||||
DeltaTimer timer = new();
|
||||
Ping ping;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
public int frameRate;
|
||||
// Update is called once per frame
|
||||
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(pingAddress);
|
||||
}
|
||||
}
|
||||
public override string GetName()
|
||||
{
|
||||
return nameof(ShowProfiler);
|
||||
}
|
||||
public override object GetDiagnostics()
|
||||
{
|
||||
Dictionary<string, string> dictioanry = new();
|
||||
dictioanry.Add(nameof(fpsOutput), fpsOutput ? "有效" : "未定义");
|
||||
dictioanry.Add(nameof(pingOutput), pingOutput ? "有效" : "未定义");
|
||||
dictioanry.Add("FPS", timer);
|
||||
return dictioanry;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user