From 4c134af495dd97def43b3fee1f76c50969b84b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Mon, 27 Apr 2026 11:01:30 +0800 Subject: [PATCH] update --- Editor/Timer/TimerComponentInspector.cs | 10 +++++----- ...ebuggerComponent.TimerInformationWindow.cs | 12 +++++------ ...viceDebugView.cs => ITimerServiceDebug.cs} | 2 +- ...iew.cs.meta => ITimerServiceDebug.cs.meta} | 0 Runtime/Timer/TimerService.cs | 20 ++++--------------- 5 files changed, 16 insertions(+), 28 deletions(-) rename Runtime/Timer/{ITimerServiceDebugView.cs => ITimerServiceDebug.cs} (92%) rename Runtime/Timer/{ITimerServiceDebugView.cs.meta => ITimerServiceDebug.cs.meta} (100%) diff --git a/Editor/Timer/TimerComponentInspector.cs b/Editor/Timer/TimerComponentInspector.cs index 31a26b6..75da6ce 100644 --- a/Editor/Timer/TimerComponentInspector.cs +++ b/Editor/Timer/TimerComponentInspector.cs @@ -56,7 +56,7 @@ namespace AlicizaX.Timer.Editor return; } - if (timerService is not ITimerServiceDebugView debugView) + if (timerService is not ITimerServiceDebug debugView) { return; } @@ -80,7 +80,7 @@ namespace AlicizaX.Timer.Editor #endif } - private void DrawTimerList(ITimerServiceDebugView debugView, int activeCount) + private void DrawTimerList(ITimerServiceDebug debug, int activeCount) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Active Timers", EditorStyles.boldLabel); @@ -92,7 +92,7 @@ namespace AlicizaX.Timer.Editor } EnsureTimerBuffer(activeCount); - int timerCount = debugView.GetAllTimers(_timerBuffer); + int timerCount = debug.GetAllTimers(_timerBuffer); int displayCount = Mathf.Min(timerCount, MAX_DISPLAY_COUNT); if (displayCount < timerCount) @@ -120,7 +120,7 @@ namespace AlicizaX.Timer.Editor } #if UNITY_EDITOR - private void DrawLeakDetection(ITimerServiceDebugView debugView, int activeCount) + private void DrawLeakDetection(ITimerServiceDebug debug, int activeCount) { if (activeCount <= 0) { @@ -128,7 +128,7 @@ namespace AlicizaX.Timer.Editor } EnsureLeakBuffer(activeCount); - int staleCount = debugView.GetStaleOneShotTimers(_leakBuffer); + int staleCount = debug.GetStaleOneShotTimers(_leakBuffer); if (staleCount <= 0) { return; diff --git a/Runtime/Debugger/DebuggerComponent.TimerInformationWindow.cs b/Runtime/Debugger/DebuggerComponent.TimerInformationWindow.cs index 6dbaba9..e729dcc 100644 --- a/Runtime/Debugger/DebuggerComponent.TimerInformationWindow.cs +++ b/Runtime/Debugger/DebuggerComponent.TimerInformationWindow.cs @@ -17,7 +17,7 @@ namespace AlicizaX.Debugger.Runtime public Label Value; } - private ITimerServiceDebugView m_TimerDebugView; + private ITimerServiceDebug _mTimerDebug; private TimerDebugInfo[] m_TimerInfos; private Label m_SectionTitleLabel; private Label m_ActiveCountLabel; @@ -31,12 +31,12 @@ namespace AlicizaX.Debugger.Runtime public override void Initialize(params object[] args) { - m_TimerDebugView = AppServices.Require() as ITimerServiceDebugView; + _mTimerDebug = AppServices.Require() as ITimerServiceDebug; } protected override void BuildWindow(VisualElement root) { - if (m_TimerDebugView == null) + if (_mTimerDebug == null) { return; } @@ -74,12 +74,12 @@ namespace AlicizaX.Debugger.Runtime private void RefreshContent() { - if (m_TimerDebugView == null) + if (_mTimerDebug == null) { return; } - m_TimerDebugView.GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount); + _mTimerDebug.GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount); float poolUsage = poolCapacity > 0 ? (float)activeCount / poolCapacity : 0f; m_ActiveCountLabel.text = activeCount.ToString(); @@ -100,7 +100,7 @@ namespace AlicizaX.Debugger.Runtime } EnsureTimerInfoBuffer(activeCount); - int timerCount = m_TimerDebugView.GetAllTimers(m_TimerInfos); + int timerCount = _mTimerDebug.GetAllTimers(m_TimerInfos); int displayCount = timerCount > MAX_DISPLAY_COUNT ? MAX_DISPLAY_COUNT : timerCount; m_SectionTitleLabel.text = Utility.Text.Format("Active Timers ({0})", timerCount); diff --git a/Runtime/Timer/ITimerServiceDebugView.cs b/Runtime/Timer/ITimerServiceDebug.cs similarity index 92% rename from Runtime/Timer/ITimerServiceDebugView.cs rename to Runtime/Timer/ITimerServiceDebug.cs index c72feb0..9c33229 100644 --- a/Runtime/Timer/ITimerServiceDebugView.cs +++ b/Runtime/Timer/ITimerServiceDebug.cs @@ -11,7 +11,7 @@ namespace AlicizaX.Timer.Runtime public float CreationTime; } - internal interface ITimerServiceDebugView + internal interface ITimerServiceDebug { int GetAllTimers(TimerDebugInfo[] results); diff --git a/Runtime/Timer/ITimerServiceDebugView.cs.meta b/Runtime/Timer/ITimerServiceDebug.cs.meta similarity index 100% rename from Runtime/Timer/ITimerServiceDebugView.cs.meta rename to Runtime/Timer/ITimerServiceDebug.cs.meta diff --git a/Runtime/Timer/TimerService.cs b/Runtime/Timer/TimerService.cs index abf4910..729da95 100644 --- a/Runtime/Timer/TimerService.cs +++ b/Runtime/Timer/TimerService.cs @@ -42,9 +42,7 @@ namespace AlicizaX.Timer.Runtime public bool IsActive; public byte HandlerType; -#if UNITY_EDITOR public float CreationTime; -#endif [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Clear() @@ -64,16 +62,14 @@ namespace AlicizaX.Timer.Runtime IsUnscaled = false; IsActive = false; HandlerType = 0; -#if UNITY_EDITOR CreationTime = 0f; -#endif } } [UnityEngine.Scripting.Preserve] [Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)] - internal sealed class TimerService : ServiceBase, ITimerService, IServiceTickable, ITimerServiceDebugView + internal sealed class TimerService : ServiceBase, ITimerService, IServiceTickable, ITimerServiceDebug { private const int MAX_CAPACITY = 256; private const int HANDLE_INDEX_BITS = 9; @@ -83,9 +79,7 @@ namespace AlicizaX.Timer.Runtime private const byte HANDLER_NO_ARGS = 0; private const byte HANDLER_GENERIC = 1; -#if UNITY_EDITOR private const float LEAK_DETECTION_THRESHOLD = 300f; -#endif private readonly TimerInfo[] _timerPool; private readonly int[] _freeIndices; @@ -474,7 +468,7 @@ namespace AlicizaX.Timer.Runtime public int Order => 0; - void ITimerServiceDebugView.GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount) + void ITimerServiceDebug.GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount) { activeCount = _activeCount; poolCapacity = MAX_CAPACITY; @@ -482,7 +476,7 @@ namespace AlicizaX.Timer.Runtime freeCount = _freeCount; } - int ITimerServiceDebugView.GetAllTimers(TimerDebugInfo[] results) + int ITimerServiceDebug.GetAllTimers(TimerDebugInfo[] results) { if (results == null || results.Length == 0) { @@ -501,8 +495,7 @@ namespace AlicizaX.Timer.Runtime return count; } -#if UNITY_EDITOR - int ITimerServiceDebugView.GetStaleOneShotTimers(TimerDebugInfo[] results) + int ITimerServiceDebug.GetStaleOneShotTimers(TimerDebugInfo[] results) { if (results == null || results.Length == 0) { @@ -534,7 +527,6 @@ namespace AlicizaX.Timer.Runtime return count; } -#endif [MethodImpl(MethodImplOptions.AggressiveInlining)] private int AcquireTimerIndex() @@ -570,9 +562,7 @@ namespace AlicizaX.Timer.Runtime timer.IsActive = true; timer.HandlerType = HANDLER_NO_ARGS; -#if UNITY_EDITOR timer.CreationTime = Time.realtimeSinceStartup; -#endif } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -786,9 +776,7 @@ namespace AlicizaX.Timer.Runtime info.IsLoop = timer.IsLoop; info.IsRunning = timer.IsRunning; info.IsUnscaled = timer.IsUnscaled; -#if UNITY_EDITOR info.CreationTime = timer.CreationTime; -#endif } } }