Example #1
0
 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();
 }
Example #2
0
        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);
            }
        }
Example #3
0
 protected override void OnDisable()
 {
     base.OnDisable();
     NavigationInputBase.Clicked -= OnNavigationClicked;
     NavigationRegister.Remove(this);
 }