fix
This commit is contained in:
parent
43e6a6ba83
commit
ab0bc3bcf9
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Controls;
|
||||
@ -127,17 +124,17 @@ public static class InputDeviceWatcher
|
||||
|
||||
InputSystem.onDeviceChange += OnDeviceChange;
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private static void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
private static void OnPlayModeStateChanged(UnityEditor.PlayModeStateChange state)
|
||||
{
|
||||
if (state == PlayModeStateChange.ExitingPlayMode)
|
||||
if (state == UnityEditor.PlayModeStateChange.ExitingPlayMode)
|
||||
{
|
||||
Dispose();
|
||||
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
|
||||
UnityEditor.EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -464,7 +464,11 @@ namespace AlicizaX.UI
|
||||
/// <returns>成功移动焦点时返回 <see langword="true"/>;否则返回 <see langword="false"/>。</returns>
|
||||
private bool MoveFocus(MoveDirection direction)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
return RecyclerView != null && RecyclerView.NavigationController.TryMove(Holder, direction, NavigationOptions);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -9,14 +9,19 @@ namespace AlicizaX.UI
|
||||
IPointerClickHandler,
|
||||
IPointerEnterHandler,
|
||||
IPointerExitHandler,
|
||||
#if UX_NAVIGATION
|
||||
ISelectHandler,
|
||||
IDeselectHandler,
|
||||
IMoveHandler,
|
||||
#endif
|
||||
IBeginDragHandler,
|
||||
IDragHandler,
|
||||
IEndDragHandler,
|
||||
IEndDragHandler
|
||||
#if UX_NAVIGATION
|
||||
,
|
||||
ISubmitHandler,
|
||||
ICancelHandler
|
||||
#endif
|
||||
{
|
||||
private IItemInteractionHost host;
|
||||
private ItemInteractionFlags flags;
|
||||
@ -100,26 +105,32 @@ namespace AlicizaX.UI
|
||||
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
if ((flags & ItemInteractionFlags.Select) != 0)
|
||||
{
|
||||
host?.HandleSelect(eventData);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
if ((flags & ItemInteractionFlags.Deselect) != 0)
|
||||
{
|
||||
host?.HandleDeselect(eventData);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnMove(AxisEventData eventData)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
if ((flags & ItemInteractionFlags.Move) != 0)
|
||||
{
|
||||
host?.HandleMove(eventData);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
@ -157,18 +168,22 @@ namespace AlicizaX.UI
|
||||
|
||||
public void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
if ((flags & ItemInteractionFlags.Submit) != 0)
|
||||
{
|
||||
host?.HandleSubmit(eventData);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
if ((flags & ItemInteractionFlags.Cancel) != 0)
|
||||
{
|
||||
host?.HandleCancel(eventData);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void EnsureFocusAnchor()
|
||||
@ -179,11 +194,18 @@ namespace AlicizaX.UI
|
||||
}
|
||||
|
||||
focusAnchor = GetComponent<Selectable>();
|
||||
#if !UX_NAVIGATION
|
||||
if (focusAnchor is RecyclerItemSelectable)
|
||||
{
|
||||
focusAnchor = null;
|
||||
}
|
||||
#endif
|
||||
if (focusAnchor != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if UX_NAVIGATION
|
||||
ownedSelectable = GetComponent<RecyclerItemSelectable>();
|
||||
if (ownedSelectable == null)
|
||||
{
|
||||
@ -191,6 +213,7 @@ namespace AlicizaX.UI
|
||||
}
|
||||
|
||||
focusAnchor = ownedSelectable;
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool TryGetFocusableSelectable(out Selectable selectable)
|
||||
@ -211,6 +234,12 @@ namespace AlicizaX.UI
|
||||
continue;
|
||||
}
|
||||
|
||||
#if !UX_NAVIGATION
|
||||
if (candidate is RecyclerItemSelectable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (IsSelectableFocusable(candidate))
|
||||
{
|
||||
selectable = candidate;
|
||||
@ -231,6 +260,9 @@ namespace AlicizaX.UI
|
||||
|
||||
private static bool RequiresSelection(ItemInteractionFlags interactionFlags)
|
||||
{
|
||||
#if !UX_NAVIGATION
|
||||
return false;
|
||||
#else
|
||||
const ItemInteractionFlags selectionFlags =
|
||||
ItemInteractionFlags.Select |
|
||||
ItemInteractionFlags.Deselect |
|
||||
@ -239,6 +271,7 @@ namespace AlicizaX.UI
|
||||
ItemInteractionFlags.Cancel;
|
||||
|
||||
return (interactionFlags & selectionFlags) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("INPUTSYSTEM_SUPPORT")]
|
||||
|
||||
@ -12,6 +12,10 @@ namespace AlicizaX.UI
|
||||
Navigation disabledNavigation = navigation;
|
||||
disabledNavigation.mode = Navigation.Mode.None;
|
||||
navigation = disabledNavigation;
|
||||
#if !UX_NAVIGATION
|
||||
interactable = false;
|
||||
enabled = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void OnMove(AxisEventData eventData)
|
||||
|
||||
@ -18,6 +18,11 @@ namespace AlicizaX.UI
|
||||
Navigation navigationConfig = navigation;
|
||||
navigationConfig.mode = Navigation.Mode.None;
|
||||
navigation = navigationConfig;
|
||||
#if !UX_NAVIGATION
|
||||
interactable = false;
|
||||
enabled = false;
|
||||
return;
|
||||
#endif
|
||||
recyclerView = GetComponent<RecyclerView>();
|
||||
}
|
||||
|
||||
@ -42,8 +47,12 @@ namespace AlicizaX.UI
|
||||
|
||||
private bool TryEnter(MoveDirection direction)
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
recyclerView ??= GetComponent<RecyclerView>();
|
||||
return recyclerView != null && recyclerView.TryFocusEntry(direction);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,9 @@ namespace AlicizaX.UI
|
||||
|
||||
public bool TryMove(ViewHolder currentHolder, MoveDirection direction, RecyclerNavigationOptions options)
|
||||
{
|
||||
#if !UX_NAVIGATION
|
||||
return false;
|
||||
#else
|
||||
if (recyclerView == null ||
|
||||
recyclerView.RecyclerViewAdapter == null ||
|
||||
currentHolder == null)
|
||||
@ -67,6 +70,7 @@ namespace AlicizaX.UI
|
||||
|
||||
recyclerView.TryFocusIndex(originalIndex, false, alignment);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
private int GetStep(MoveDirection direction)
|
||||
|
||||
@ -487,10 +487,12 @@ namespace AlicizaX.UI
|
||||
/// </summary>
|
||||
private void EnsureNavigationBridge()
|
||||
{
|
||||
#if UX_NAVIGATION
|
||||
if (GetComponent<RecyclerNavigationBridge>() == null)
|
||||
{
|
||||
gameObject.AddComponent<RecyclerNavigationBridge>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -34,6 +34,13 @@ namespace UnityEngine.UI
|
||||
PlayAudio(clickAudioClip);
|
||||
}
|
||||
|
||||
public override void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
base.OnSelect(eventData);
|
||||
if (eventData is PointerEventData)
|
||||
return;
|
||||
PlayAudio(hoverAudioClip);
|
||||
}
|
||||
|
||||
public virtual void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
|
||||
@ -227,6 +227,14 @@ namespace UnityEngine.UI
|
||||
PlayAudio(clickAudioClip);
|
||||
}
|
||||
|
||||
public override void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
base.OnSelect(eventData);
|
||||
if (eventData is PointerEventData)
|
||||
return;
|
||||
PlayAudio(hoverAudioClip);
|
||||
}
|
||||
|
||||
public virtual void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
InternalToggle();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user