protected override void OnEnable() { base.OnEnable(); NavigationInputBase.Clicked += OnNavigationClicked; NavigationRegister.Add(this); //TODO crutch: refactoring to navigation creating if (Application.isMobilePlatform) { this.enabled = false; return; } TrySelectCurrentElement(); }
private void OnNavigationClicked(NavigationType type) { //TODO refactoring to chain handling if (!NavigationRegister.IsCurrent(this)) { return; } if (type == NavigationType.Entered) { OnEnterClicked(); return; } var focusedObject = GetCurrentElementInFocus(); if (focusedObject != null && _components.Contains(focusedObject)) { return; } var targetDirection = DirectionType.None; switch (type) { case NavigationType.Left: targetDirection = IsHorizontalNavigationEnable ? DirectionType.Previous : DirectionType.None; break; case NavigationType.Right: targetDirection = IsHorizontalNavigationEnable ? DirectionType.Next : DirectionType.None; break; case NavigationType.Up: targetDirection = IsVerticalNavigationEnable ? DirectionType.Previous : DirectionType.None; break; case NavigationType.Down: targetDirection = IsVerticalNavigationEnable ? DirectionType.Next : DirectionType.None; break; } if (targetDirection != DirectionType.None) { SelectAnotherComponent(targetDirection); } }
protected override void OnDisable() { base.OnDisable(); NavigationInputBase.Clicked -= OnNavigationClicked; NavigationRegister.Remove(this); }