This commit is contained in:
2026-09-18 08:15:08 +08:00
parent b802668dc0
commit a8a1f6021c
61 changed files with 4449 additions and 3889 deletions
+21 -3
View File
@@ -33,6 +33,21 @@ public class EffectPool : Singleton<EffectPool>
/// autoReturn=false: 动画/UI 驱动特效(如 BJBase/DieEffect_TSY),由动画事件手动调用 Return()
/// </summary>
public GameObject Get(GameObject prefab, Vector3 position, Quaternion rotation, Transform parent, bool autoReturn)
{
return GetCore(prefab, position, rotation, parent, autoReturn);
}
/// <summary>
/// 从池中取一个特效,不设置位置/旋转——位置、大小完全保留预制体里配置好的
/// (爆奖特效用,z 也用预制体自带的,不被生成位置带偏)。
/// </summary>
public GameObject Get(GameObject prefab, Transform parent, bool autoReturn)
{
return GetCore(prefab, null, null, parent, autoReturn);
}
/// <summary>取用核心:position/rotation 传 null 时不设置,保留预制体配置好的变换</summary>
private GameObject GetCore(GameObject prefab, Vector3? position, Quaternion? rotation, Transform parent, bool autoReturn)
{
if (prefab == null) return null;
@@ -53,13 +68,16 @@ public class EffectPool : Singleton<EffectPool>
if (obj != null)
{
obj.transform.SetParent(parent, false);
obj.transform.position = position;
obj.transform.rotation = rotation;
// ⭐ 只在传入时才设置位置/旋转;不传则保留预制体配置好的位置和大小
if (position.HasValue) obj.transform.position = position.Value;
if (rotation.HasValue) obj.transform.rotation = rotation.Value;
obj.SetActive(true);
}
else
{
obj = GameObject.Instantiate(prefab, position, rotation, parent);
obj = position.HasValue
? GameObject.Instantiate(prefab, position.Value, rotation ?? Quaternion.identity, parent)
: GameObject.Instantiate(prefab, parent);
obj.SetActive(true);
}