using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BITKit { public class ShowProfiler : BITBehavior { [Header(Constant.Header.Settings)] [SubclassSelector, SerializeReference] public References pingAddress; [SerializeField] private IntervalUpdate fpsInterval; [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; resolutionOutput?.Set(Screen.currentResolution.ToString()); if (fpsInterval.AllowUpdate) 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); } frameRateOutput?.Set(Application.targetFrameRate is -1 or 0 ? "Unlimited" : Application.targetFrameRate.ToString()); } public override string GetName() { return nameof(ShowProfiler); } } }