This commit is contained in:
陈思海 2025-12-17 17:15:24 +08:00
parent ca28bb2c55
commit c9740c3fb6

View File

@ -144,8 +144,6 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
if (old._mTogSelected && old.m_Mode == ButtonModeType.Toggle)
old.SetState(SelectionState.Selected);
else
old.SetState(SelectionState.Normal);
}
if (newLocked != null)
@ -343,10 +341,6 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
m_IsNavFocused = true;
// 变更:当通过 EventSystem.current.SetSelectedGameObject(...) 选中时,
// 也要像 Focus() 一样将静态锁设置到当前按钮(除非已经是自己)。
// 这样外部直接调用 EventSystem.current.SetSelectedGameObject(...) 就能生效,
// 无需再调用 Focus().
if (s_LockedButton != this)
{
SetLockedButton(this);
@ -381,10 +375,8 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
if (selectionIsNull)
{
// 统一走封装入口清理锁
SetLockedButton(null);
// 额外保证本实例的本地标志被清掉(以防极端顺序仍然残留)
m_IsNavFocused = false;
s_LockedButton = null;
m_IsFocusLocked = false;
}
@ -543,15 +535,9 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
ApplyVisualState(state, true);
}
/// <summary>
/// 覆盖基类的 ApplyVisualState先由基类处理 MainTransition再处理 child transitions保持原逻辑
/// </summary>
public override void ApplyVisualState(SelectionState state, bool instant)
{
// main transition 由基类处理
base.ApplyVisualState(state, instant);
// child transitions 保持原有处理UXButton 特有)
for (int i = 0; i < m_ChildTransitions.Count; i++)
base.ApplyTransition(m_ChildTransitions[i], state, instant);
}