This commit is contained in:
陈思海 2026-04-28 16:29:44 +08:00
parent 4cf5eb57d2
commit 6a2e807fcc
5 changed files with 28 additions and 44 deletions

View File

@ -23,7 +23,7 @@ namespace AlicizaX.Debugger.Runtime
public VisualElement Fill;
}
private ITimerServiceDebug _mTimerDebug;
private ITimerService _mTimerDebug;
private readonly TimerDebugInfo[] m_TimerInfos = new TimerDebugInfo[MAX_DISPLAY_COUNT];
private readonly RowView[] m_TimerRows = new RowView[MAX_DISPLAY_COUNT];
private VisualElement m_ActiveUsageFill;
@ -35,7 +35,7 @@ namespace AlicizaX.Debugger.Runtime
public override void Initialize(params object[] args)
{
_mTimerDebug = AppServices.Require<ITimerService>() as ITimerServiceDebug;
_mTimerDebug = AppServices.Require<ITimerService>();
}
public override void OnEnter()

View File

@ -1,5 +1,21 @@
using System;
public static class TimerDebugFlags
{
public const byte Running = 1 << 0;
public const byte Loop = 1 << 1;
public const byte Unscaled = 1 << 2;
}
public struct TimerDebugInfo
{
public ulong TimerHandle;
public float LeftTime;
public float Duration;
public float Age;
public byte Flags;
}
namespace AlicizaX.Timer.Runtime
{
[UnityEngine.Scripting.Preserve]
@ -13,5 +29,11 @@ namespace AlicizaX.Timer.Runtime
float GetLeftTime(ulong timerHandle);
void Restart(ulong timerHandle);
void RemoveTimer(ulong timerHandle);
int GetAllTimers(TimerDebugInfo[] results);
void GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount);
int GetStaleOneShotTimers(TimerDebugInfo[] results);
}
}

View File

@ -1,27 +0,0 @@
namespace AlicizaX.Timer.Runtime
{
internal static class TimerDebugFlags
{
public const byte Running = 1 << 0;
public const byte Loop = 1 << 1;
public const byte Unscaled = 1 << 2;
}
internal struct TimerDebugInfo
{
public ulong TimerHandle;
public float LeftTime;
public float Duration;
public float Age;
public byte Flags;
}
internal interface ITimerServiceDebug
{
int GetAllTimers(TimerDebugInfo[] results);
void GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount);
int GetStaleOneShotTimers(TimerDebugInfo[] results);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5b7cf36ada40b944f8c506e3cd8ddd12
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -22,7 +22,7 @@ namespace AlicizaX.Timer.Runtime
[UnityEngine.Scripting.Preserve]
[Il2CppSetOption(Option.NullChecks, false)]
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
internal sealed class TimerService : ServiceBase, ITimerService, IServiceTickable, ITimerServiceDebug
internal sealed class TimerService : ServiceBase, ITimerService, IServiceTickable
{
private const int PAGE_SHIFT = 8;
private const int PAGE_SIZE = 1 << PAGE_SHIFT;
@ -443,7 +443,7 @@ namespace AlicizaX.Timer.Runtime
public int Order => 0;
void ITimerServiceDebug.GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount)
void ITimerService.GetStatistics(out int activeCount, out int poolCapacity, out int peakActiveCount, out int freeCount)
{
activeCount = _activeCount;
poolCapacity = _slotCapacity;
@ -451,7 +451,7 @@ namespace AlicizaX.Timer.Runtime
freeCount = _freeCount;
}
int ITimerServiceDebug.GetAllTimers(TimerDebugInfo[] results)
int ITimerService.GetAllTimers(TimerDebugInfo[] results)
{
if (results == null || results.Length == 0)
{
@ -470,7 +470,7 @@ namespace AlicizaX.Timer.Runtime
return count;
}
int ITimerServiceDebug.GetStaleOneShotTimers(TimerDebugInfo[] results)
int ITimerService.GetStaleOneShotTimers(TimerDebugInfo[] results)
{
if (results == null || results.Length == 0)
{