NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/InformationShower.cs

32 lines
815 B
C#

using UnityEngine;
public class InformationShower : MonoBehaviour
{
#if DEVELOPMENT_BUILD || DEBUG
[SerializeField]
private float _fpsRefreshTime = 0.1f;
private float _tickTime;
private int _tickFrameCount;
private int _frameRate;
private GUIStyle _labelStyle;
void Update()
{
_tickTime += Time.deltaTime;
_tickFrameCount++;
if (_tickTime >= _fpsRefreshTime)
{
_frameRate = Mathf.RoundToInt(1f / (_tickTime / _tickFrameCount));
_tickTime = 0f;
_tickFrameCount = 0;
}
}
private void OnGUI()
{
_labelStyle ??= GUI.skin.label;
_labelStyle.fontSize = 60;
GUI.Label(new Rect(Screen.width / 2f - 100f, 20f, 300f, 200f), $"FPS:{_frameRate}", _labelStyle);
}
#endif
}