1
This commit is contained in:
@@ -29,6 +29,7 @@ using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +91,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
public Transform poolRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 非 UI 爆奖特效统一父节点。
|
||||
/// 非 UI 爆奖特效统一父节点(挂在场景根节点,不挂 UI 节点下)。
|
||||
/// 仅装载那些"原本挂在 UIManager.uiRoot 下(不会随房间退出自动销毁)"
|
||||
/// 或"原本无父对象(世界空间特效)"的爆奖特效:
|
||||
/// - BJEndUI 系列(BJEventBase/GSL/FLXJ 的 EndBJ)
|
||||
@@ -100,9 +101,21 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
/// - Boss鱼/特殊Boss isToUI=false 分支的 currEffect_DieAward
|
||||
/// UI 爆奖(挂在 subPanelParent/subPanelParent.parent 下的金币飞、分数版等)
|
||||
/// 不挂这里,由 UIManager 卸载游戏主面板时自动清理。
|
||||
/// EnterRoom 时创建挂在 UIManager.uiRoot 下,ExitRoom 时整节点销毁。
|
||||
/// ⭐ 本节点不能删除:ExitRoom 只清空子物体;
|
||||
/// 意外被删除/为 null 时取值会自动在场景根节点重建(不建到 UI 节点)。
|
||||
/// </summary>
|
||||
public Transform bjEffectRoot;
|
||||
[FormerlySerializedAs("bjEffectRoot")]
|
||||
[SerializeField] private Transform _bjEffectRoot;
|
||||
|
||||
/// <summary>爆奖特效统一父节点:为 null(意外删除)时自动在场景根节点重建</summary>
|
||||
public Transform bjEffectRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_bjEffectRoot == null) EnsureBJEffectRoot();
|
||||
return _bjEffectRoot;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>当前房间可生成鱼列表(与 NativeArray 下标对齐)</summary>
|
||||
public List<RoomFishDetailConfig> spawnList;
|
||||
@@ -420,20 +433,15 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建爆奖特效统一父节点(挂在 UIManager.uiRoot 下)。
|
||||
/// 创建爆奖特效统一父节点(挂在场景根节点,不挂 UI 节点下)。
|
||||
/// 已存在则不重复创建。所有爆奖相关 Instantiate 都应使用此节点作为父对象。
|
||||
/// </summary>
|
||||
private void EnsureBJEffectRoot()
|
||||
{
|
||||
if (bjEffectRoot != null) return;
|
||||
var go = new GameObject("BJEffectRoot");
|
||||
go.transform.SetParent(UIManager.Instance.uiRoot, false);
|
||||
var rect = go.AddComponent<RectTransform>();
|
||||
rect.anchorMin = Vector2.zero;
|
||||
rect.anchorMax = Vector2.one;
|
||||
rect.offsetMin = Vector2.zero;
|
||||
rect.offsetMax = Vector2.zero;
|
||||
bjEffectRoot = go.transform;
|
||||
if (_bjEffectRoot != null) return;
|
||||
// ⭐ 挂场景根节点(不挂 UIManager.uiRoot):世界空间爆奖特效直接用世界坐标摆放
|
||||
var go = new GameObject("bjEffectRoot");
|
||||
_bjEffectRoot = go.transform;
|
||||
}
|
||||
|
||||
/// <summary>根据当前 GameType 绑定对应 UI 面板到 currGameType。</summary>
|
||||
@@ -1357,15 +1365,15 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
Destroy(item.gameObject);
|
||||
|
||||
}
|
||||
// ⭐ 销毁爆奖特效父节点:所有挂在 bjEffectRoot 下的爆奖特效
|
||||
// (Boss 分数版/加分弹出/BJEndUI/特殊爆奖等) 会一并被销毁,
|
||||
// ⭐ 不销毁 bjEffectRoot 本身:只清空其下的爆奖特效子物体
|
||||
// (Boss 分数版/加分弹出/BJEndUI/特殊爆奖等),
|
||||
// 防止退出房间时残留未结束的爆奖协程/动画造成的内存泄漏
|
||||
if (bjEffectRoot != null)
|
||||
if (_bjEffectRoot != null)
|
||||
{
|
||||
Destroy(bjEffectRoot.gameObject);
|
||||
bjEffectRoot = null;
|
||||
for (int i = _bjEffectRoot.childCount - 1; i >= 0; i--)
|
||||
Destroy(_bjEffectRoot.GetChild(i).gameObject);
|
||||
}
|
||||
// ⭐ 清理特效池:bjEffectRoot 销毁后池内对象失效,清空避免复用已销毁对象
|
||||
// ⭐ 清理特效池:bjEffectRoot 下的特效子物体销毁后池内对象失效,清空避免复用已销毁对象
|
||||
EffectPool.Instance.ClearAll();
|
||||
//for (int i = fishDatas_hashCodekey.childCount - 1; i >= 0; i--)
|
||||
// Destroy(fishRoot.GetChild(i).gameObject);
|
||||
@@ -1982,9 +1990,10 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
if (bossCtrl.isToUI)
|
||||
{
|
||||
// ⭐ 池化:UI 空间 Boss 爆奖,动画事件播完手动回池
|
||||
// ⭐ 不设置位置:位置/大小用爆奖预制体里配置好的(z 也用预制体自带的)
|
||||
bossCtrl.currEffect_DieAward = EffectPool.Instance.Get(
|
||||
monster.effect_DieAward != null ? monster.effect_DieAward : dieFXPrefabAwardTmp,
|
||||
monster.transform.position, Quaternion.identity, currGameType.subPanelParent.parent,
|
||||
currGameType.subPanelParent.parent,
|
||||
autoReturn: false);
|
||||
}
|
||||
else
|
||||
@@ -1992,7 +2001,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
// isToUI=false:世界空间特效,无 UI 父对象 → 挂 bjEffectRoot 统一管理(池化)
|
||||
bossCtrl.currEffect_DieAward = EffectPool.Instance.Get(
|
||||
monster.effect_DieAward != null ? monster.effect_DieAward : dieFXPrefabAwardTmp,
|
||||
monster.transform.position, Quaternion.identity, bjEffectRoot,
|
||||
bjEffectRoot,
|
||||
autoReturn: false);
|
||||
}
|
||||
bossCtrl.action_effect_DieAward?.Invoke(bossCtrl.currEffect_DieAward);
|
||||
@@ -2197,9 +2206,10 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
if (bossCtrl.isToUI)
|
||||
{
|
||||
// ⭐ 池化:UI 空间 Boss 爆奖,动画事件播完手动回池
|
||||
// ⭐ 不设置位置:位置/大小用爆奖预制体里配置好的(z 也用预制体自带的)
|
||||
bossCtrl.currEffect_DieAward = EffectPool.Instance.Get(
|
||||
monster.effect_DieAward != null ? monster.effect_DieAward : dieFXPrefabAwardTmp,
|
||||
monster.transform.position, Quaternion.identity, currGameType.subPanelParent.parent,
|
||||
currGameType.subPanelParent.parent,
|
||||
autoReturn: false);
|
||||
}
|
||||
else
|
||||
@@ -2207,7 +2217,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
// isToUI=false:世界空间特效,无 UI 父对象 → 挂 bjEffectRoot 统一管理(池化)
|
||||
bossCtrl.currEffect_DieAward = EffectPool.Instance.Get(
|
||||
monster.effect_DieAward != null ? monster.effect_DieAward : dieFXPrefabAwardTmp,
|
||||
monster.transform.position, Quaternion.identity, bjEffectRoot,
|
||||
bjEffectRoot,
|
||||
autoReturn: false);
|
||||
}
|
||||
bossCtrl.action_effect_DieAward?.Invoke(bossCtrl.currEffect_DieAward);
|
||||
|
||||
Reference in New Issue
Block a user