fix
This commit is contained in:
parent
c8bb190c2e
commit
85d9a87ccb
@ -260,10 +260,11 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
|
|||||||
if (EventSystem.current != null)
|
if (EventSystem.current != null)
|
||||||
EventSystem.current.SetSelectedGameObject(gameObject, eventData);
|
EventSystem.current.SetSelectedGameObject(gameObject, eventData);
|
||||||
|
|
||||||
SetLockedButton(this);
|
|
||||||
|
|
||||||
UISystemProfilerApi.AddMarker("Button.onClick", this);
|
UISystemProfilerApi.AddMarker("Button.onClick", this);
|
||||||
m_OnClick?.Invoke();
|
m_OnClick?.Invoke();
|
||||||
|
|
||||||
|
if (IsStillSelected())
|
||||||
|
SetLockedButton(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -279,7 +280,9 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
|
|||||||
{
|
{
|
||||||
if (EventSystem.current != null)
|
if (EventSystem.current != null)
|
||||||
EventSystem.current.SetSelectedGameObject(gameObject, eventData);
|
EventSystem.current.SetSelectedGameObject(gameObject, eventData);
|
||||||
SetLockedButton(this);
|
|
||||||
|
if (IsStillSelected())
|
||||||
|
SetLockedButton(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,19 +312,19 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
|
|||||||
m_HasExitedWhileDown = false;
|
m_HasExitedWhileDown = false;
|
||||||
ForceSetState(SelectionState.Pressed);
|
ForceSetState(SelectionState.Pressed);
|
||||||
|
|
||||||
|
|
||||||
PlayAudio(clickAudioClip);
|
PlayAudio(clickAudioClip);
|
||||||
|
|
||||||
|
|
||||||
if (m_Mode == ButtonModeType.Toggle)
|
if (m_Mode == ButtonModeType.Toggle)
|
||||||
{
|
{
|
||||||
_resetRoutine = StartCoroutine(SubmitToggleDeferredRoutine());
|
_resetRoutine = StartCoroutine(SubmitToggleDeferredRoutine());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ① 先执行回调(可能切走焦点)
|
||||||
HandleClick();
|
HandleClick();
|
||||||
|
|
||||||
if (navigation.mode != UXNavigation.Mode.None)
|
// ② 只在“焦点仍在自己”时才锁
|
||||||
|
if (navigation.mode != UXNavigation.Mode.None && IsStillSelected())
|
||||||
SetLockedButton(this);
|
SetLockedButton(this);
|
||||||
|
|
||||||
if (navigation.mode != UXNavigation.Mode.None && m_Mode == ButtonModeType.Normal)
|
if (navigation.mode != UXNavigation.Mode.None && m_Mode == ButtonModeType.Normal)
|
||||||
@ -439,23 +442,23 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
|
|||||||
Animator.ResetTrigger(id);
|
Animator.ResetTrigger(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLockedButton(this);
|
if (IsStillSelected())
|
||||||
ApplyVisualState(SelectionState.Selected, false);
|
{
|
||||||
|
SetLockedButton(this);
|
||||||
|
ApplyVisualState(SelectionState.Selected, false);
|
||||||
|
}
|
||||||
|
|
||||||
_resetRoutine = null;
|
_resetRoutine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IEnumerator SubmitToggleDeferredRoutine()
|
private IEnumerator SubmitToggleDeferredRoutine()
|
||||||
{
|
{
|
||||||
yield return null;
|
yield return null;
|
||||||
|
|
||||||
|
|
||||||
yield return _waitFadeDuration;
|
yield return _waitFadeDuration;
|
||||||
|
|
||||||
|
|
||||||
HandleClick();
|
HandleClick();
|
||||||
|
|
||||||
|
|
||||||
if (Animator)
|
if (Animator)
|
||||||
{
|
{
|
||||||
foreach (int id in _animTriggerCache.Values)
|
foreach (int id in _animTriggerCache.Values)
|
||||||
@ -465,20 +468,19 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
|
|||||||
m_IsDown = false;
|
m_IsDown = false;
|
||||||
m_HasExitedWhileDown = false;
|
m_HasExitedWhileDown = false;
|
||||||
|
|
||||||
|
bool stillFocused = IsStillSelected();
|
||||||
bool stillFocused = EventSystem.current != null && EventSystem.current.currentSelectedGameObject == gameObject;
|
if (stillFocused)
|
||||||
if (stillFocused || m_IsNavFocused)
|
|
||||||
SetState(SelectionState.Selected);
|
SetState(SelectionState.Selected);
|
||||||
else
|
else
|
||||||
SetState(_mTogSelected ? SelectionState.Selected : SelectionState.Normal);
|
SetState(_mTogSelected ? SelectionState.Selected : SelectionState.Normal);
|
||||||
|
|
||||||
|
if (navigation.mode != UXNavigation.Mode.None && stillFocused)
|
||||||
if (navigation.mode != UXNavigation.Mode.None)
|
|
||||||
SetLockedButton(this);
|
SetLockedButton(this);
|
||||||
|
|
||||||
_resetRoutine = null;
|
_resetRoutine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IEnumerator ResetAfterSubmit()
|
private IEnumerator ResetAfterSubmit()
|
||||||
{
|
{
|
||||||
yield return _waitFadeDuration;
|
yield return _waitFadeDuration;
|
||||||
@ -490,10 +492,11 @@ public class UXButton : UXSelectable, IButton, IPointerClickHandler, ISubmitHand
|
|||||||
|
|
||||||
#region Utility
|
#region Utility
|
||||||
|
|
||||||
private void ForceSetState(SelectionState state)
|
private bool IsStillSelected()
|
||||||
{
|
{
|
||||||
// 链接到基类的 ForceSetState
|
if (EventSystem.current != null)
|
||||||
base.ForceSetState(state);
|
return EventSystem.current.currentSelectedGameObject == gameObject;
|
||||||
|
return m_IsNavFocused;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user