diff --git a/Runtime/UXComponent/Navigation/UXNavigationRuntime.cs b/Runtime/UXComponent/Navigation/UXNavigationRuntime.cs index ebc6e1a..782045e 100644 --- a/Runtime/UXComponent/Navigation/UXNavigationRuntime.cs +++ b/Runtime/UXComponent/Navigation/UXNavigationRuntime.cs @@ -211,7 +211,7 @@ namespace UnityEngine.UI foreach (Transform layerRoot in _interactiveLayerRoots) { - if (layerRoot == null) + if (layerRoot == null || IsNavigationSkipped(layerRoot)) { continue; } @@ -220,7 +220,9 @@ namespace UnityEngine.UI for (int i = 0; i < holders.Length; i++) { UIHolderObjectBase holder = holders[i]; - if (holder == null || holder.GetComponent() != null) + if (holder == null + || holder.GetComponent() != null + || IsNavigationSkipped(holder.transform)) { continue; } @@ -287,7 +289,14 @@ namespace UnityEngine.UI return false; } - return TryGetInteractiveLayerRoot(scope.transform, out _); + return !IsNavigationSkipped(scope.transform) + && scope.HasAvailableSelectable() + && TryGetInteractiveLayerRoot(scope.transform, out _); + } + + private static bool IsNavigationSkipped(Transform current) + { + return current != null && current.GetComponentInParent(true) != null; } private bool TryGetInteractiveLayerRoot(Transform current, out Transform layerRoot) diff --git a/Runtime/UXComponent/Navigation/UXNavigationScope.cs b/Runtime/UXComponent/Navigation/UXNavigationScope.cs index 9468a8e..3d91d17 100644 --- a/Runtime/UXComponent/Navigation/UXNavigationScope.cs +++ b/Runtime/UXComponent/Navigation/UXNavigationScope.cs @@ -160,6 +160,26 @@ namespace UnityEngine.UI return null; } + internal bool HasAvailableSelectable() + { + RefreshSelectableCache(); + + if (IsSelectableValid(_defaultSelectable)) + { + return true; + } + + for (int i = 0; i < _cachedSelectables.Count; i++) + { + if (IsSelectableValid(_cachedSelectables[i])) + { + return true; + } + } + + return false; + } + internal void RecordSelection(GameObject selectedObject) { if (!_rememberLastSelection || selectedObject == null) diff --git a/Runtime/UXComponent/Navigation/UXNavigationSkip.cs b/Runtime/UXComponent/Navigation/UXNavigationSkip.cs new file mode 100644 index 0000000..f13dfe9 --- /dev/null +++ b/Runtime/UXComponent/Navigation/UXNavigationSkip.cs @@ -0,0 +1,10 @@ +#if INPUTSYSTEM_SUPPORT +namespace UnityEngine.UI +{ + [DisallowMultipleComponent] + [AddComponentMenu("UI/UX Navigation Skip")] + public sealed class UXNavigationSkip : MonoBehaviour + { + } +} +#endif diff --git a/Runtime/UXComponent/Navigation/UXNavigationSkip.cs.meta b/Runtime/UXComponent/Navigation/UXNavigationSkip.cs.meta new file mode 100644 index 0000000..0dd682f --- /dev/null +++ b/Runtime/UXComponent/Navigation/UXNavigationSkip.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4d9f2572962f46368405e4b5abf32d2a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: