42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System.Globalization;
|
|
using System.Text;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace Cryville.EEW.Unity.UI {
|
|
[RequireComponent(typeof(TMP_Text))]
|
|
class StatusView : MonoBehaviour {
|
|
TMP_Text _textView;
|
|
|
|
void Awake() {
|
|
_textView = GetComponent<TMP_Text>();
|
|
}
|
|
|
|
readonly StringBuilder _sb = new();
|
|
readonly char[] _buffer = new char[256];
|
|
void Update() {
|
|
_sb.Clear();
|
|
_sb.AppendFormat(
|
|
CultureInfo.InvariantCulture,
|
|
"FPS: i{0:0} / s{1:0}\n",
|
|
1 / Time.deltaTime,
|
|
1 / Time.smoothDeltaTime
|
|
);
|
|
_sb.AppendFormat(
|
|
CultureInfo.InvariantCulture,
|
|
"SMem: {0:N0} / {1:N0}\n",
|
|
UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong(),
|
|
UnityEngine.Profiling.Profiler.GetMonoHeapSizeLong()
|
|
);
|
|
_sb.AppendFormat(
|
|
CultureInfo.InvariantCulture,
|
|
"IMem: {0:N0} / {1:N0}",
|
|
UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong(),
|
|
UnityEngine.Profiling.Profiler.GetTotalReservedMemoryLong()
|
|
);
|
|
_sb.CopyTo(0, _buffer, _sb.Length);
|
|
_textView.SetText(_buffer, 0, _sb.Length);
|
|
}
|
|
}
|
|
}
|