com.alicizax.unity.framework/Runtime/ABase/ObjectPool/ObjectPoolComponent.cs

43 lines
1.0 KiB
C#
Raw Normal View History

using AlicizaX.ObjectPool;
2025-10-11 15:18:09 +08:00
using UnityEngine;
namespace AlicizaX
{
/// <summary>
2026-04-20 13:46:44 +08:00
/// 对象池组件。
2025-10-11 15:18:09 +08:00
/// </summary>
public sealed class ObjectPoolComponent : MonoBehaviour
{
private IObjectPoolService _mObjectPoolService = null;
2025-10-11 15:18:09 +08:00
/// <summary>
2026-04-20 13:46:44 +08:00
/// 获取对象池数量。
2025-10-11 15:18:09 +08:00
/// </summary>
public int Count
{
get { return _mObjectPoolService.Count; }
2025-10-11 15:18:09 +08:00
}
private void Awake()
{
2026-04-20 13:46:44 +08:00
_mObjectPoolService = AppServices.RegisterApp(new ObjectPoolService());
2025-10-11 15:18:09 +08:00
}
private void OnDestroy()
{
_mObjectPoolService = null;
2025-10-11 15:18:09 +08:00
}
/// <summary>
2026-04-20 13:46:44 +08:00
/// 获取所有对象池。
2025-10-11 15:18:09 +08:00
/// </summary>
2026-04-20 13:46:44 +08:00
/// <param name="sort">是否根据对象池的优先级排序。</param>
/// <returns>所有对象池。</returns>
2025-10-11 15:18:09 +08:00
public ObjectPoolBase[] GetAllObjectPools(bool sort)
{
return _mObjectPoolService.GetAllObjectPools(sort);
2025-10-11 15:18:09 +08:00
}
}
}