com.alicizax.unity.framework/Runtime/Timer/TimerComponent.cs

37 lines
864 B
C#
Raw Normal View History

2025-09-05 19:46:30 +08:00
using AlicizaX;
using UnityEngine;
namespace AlicizaX.Timer.Runtime
{
[DisallowMultipleComponent]
[AddComponentMenu("Game Framework/Timer")]
[UnityEngine.Scripting.Preserve]
public sealed class TimerComponent : MonoBehaviour
2025-09-05 19:46:30 +08:00
{
private const int MIN_INITIAL_CAPACITY = 256;
[SerializeField]
[Min(MIN_INITIAL_CAPACITY)]
private int _initialCapacity = 1024;
2025-09-05 19:46:30 +08:00
private void Awake()
{
if (AppServices.TryGet<ITimerService>(out _))
{
return;
}
AppServices.RegisterApp<ITimerService>(new TimerService(_initialCapacity));
}
private void OnValidate()
{
if (_initialCapacity < MIN_INITIAL_CAPACITY)
{
_initialCapacity = MIN_INITIAL_CAPACITY;
}
2025-09-05 19:46:30 +08:00
}
}
}