尝试修改丢text的情况
This commit is contained in:
@@ -34,8 +34,18 @@ namespace Continentis.MainGame.UI
|
||||
HUD_CharacterBuffIcon buffIcon = buffIcons.Find(x => x.buff == buff);
|
||||
if (buffIcon != null)
|
||||
{
|
||||
LeanPool.Despawn(buffIcon.gameObject);
|
||||
buffIcons.Remove(buffIcon);
|
||||
buff.iconSubmodule.buffIcon = null;
|
||||
LeanPool.Despawn(buffIcon.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果逻辑上要移除 Buff,但在 UI 列表里找不到对应的 Icon,说明出事了。
|
||||
// 这可能是导致你看到“Buff图标没有正常显示”的另一个原因(状态不同步)。
|
||||
Debug.LogWarning($"[HUD] 尝试移除 Buff {buff.contentSubmodule.displayName} 的图标,但在 buffIcons 列表中未找到匹配项!可能存在状态脱节。");
|
||||
|
||||
// 可选:强制清理一遍列表中的空引用(自我修复)
|
||||
// CleanUpInvalidIcons();
|
||||
}
|
||||
UpdateHud();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,14 @@ namespace Continentis.MainGame.UI
|
||||
}
|
||||
|
||||
TMP_Text text = textList[textIndex];
|
||||
|
||||
if (text == null)
|
||||
{
|
||||
Debug.LogWarning($"Text component at index {textIndex} is null.");
|
||||
// 如果这里触发了,说明上层逻辑在尝试操作一个已经死亡的 UI 对象
|
||||
return;
|
||||
}
|
||||
|
||||
if (getText != null)
|
||||
{
|
||||
text.gameObject.SetActive(true);
|
||||
|
||||
Reference in New Issue
Block a user