com.alicizax.unity.framework/Runtime/ABase/ObjectPool/ObjectPoolComponent.cs
2026-04-20 13:46:44 +08:00

43 lines
1.0 KiB
C#

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