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 dictioanry = new(); dictioanry.Add(nameof(fpsOutput), fpsOutput ? "有效" : "未定义"); dictioanry.Add(nameof(pingOutput), pingOutput ? "有效" : "未定义"); dictioanry.Add("FPS", timer); return dictioanry; } } }