com.alicizax.unity/Runtime/ReferencePool/ReferencePoolComponent.cs
陈思海 bf0d8340af init
2025-02-07 16:04:12 +08:00

67 lines
1.8 KiB
C#

using AlicizaX;
using UnityEngine;
namespace AlicizaX.Runtime
{
/// <summary>
/// 引用池组件。
/// </summary>
[DisallowMultipleComponent]
[AddComponentMenu("Game Framework/ReferencePool")]
public sealed class ReferencePoolComponent : GameFrameworkComponent
{
[SerializeField]
private ReferenceStrictCheckType m_EnableStrictCheck = ReferenceStrictCheckType.AlwaysEnable;
/// <summary>
/// 获取或设置是否开启强制检查。
/// </summary>
public bool EnableStrictCheck
{
get
{
return ReferencePool.EnableStrictCheck;
}
set
{
ReferencePool.EnableStrictCheck = value;
if (value)
{
Log.Info("Strict checking is enabled for the Reference Pool. It will drastically affect the performance.");
}
}
}
/// <summary>
/// 游戏框架组件初始化。
/// </summary>
protected override void Awake()
{
IsAutoRegister = false;
base.Awake();
}
private void Start()
{
switch (m_EnableStrictCheck)
{
case ReferenceStrictCheckType.AlwaysEnable:
EnableStrictCheck = true;
break;
case ReferenceStrictCheckType.OnlyEnableWhenDevelopment:
EnableStrictCheck = Debug.isDebugBuild;
break;
case ReferenceStrictCheckType.OnlyEnableInEditor:
EnableStrictCheck = Application.isEditor;
break;
default:
EnableStrictCheck = false;
break;
}
}
}
}