private void Bind(NavigationItemDirection direction, Selectable selectable, Selectable next)
    {
        Navigation navigation = selectable.navigation;

        navigation.mode = Navigation.Mode.Explicit;
        switch (direction)
        {
        case NavigationItemDirection.Up:
            navigation.selectOnUp = next;
            break;

        case NavigationItemDirection.Down:
            navigation.selectOnDown = next;
            break;

        case NavigationItemDirection.Left:
            navigation.selectOnLeft = next;
            break;

        case NavigationItemDirection.Right:
            navigation.selectOnRight = next;
            break;
        }
        selectable.navigation = navigation;
    }
Beispiel #2
0
 public Selectable GetSelectableItem(NavigationItemDirection direction)
 {
     if (groupCount > 1 && (current != null || currentChild != null))
     {
         int num = -1;
         for (int i = 0; i < items.Count; i++)
         {
             if ((current != null && items[i].selectable == current) || (currentChild != null && items[i].subNavigation == currentChild))
             {
                 num = i;
                 break;
             }
         }
         if (num == -1)
         {
             return(null);
         }
         NavigationItem navigationItem = ((this.direction != NavigationDirection.Vertical || direction != NavigationItemDirection.Right) && (this.direction != 0 || direction != NavigationItemDirection.Down)) ? (((this.direction != NavigationDirection.Vertical || direction != NavigationItemDirection.Left) && (this.direction != 0 || direction != 0)) ? (((this.direction != NavigationDirection.Vertical || direction != NavigationItemDirection.Down) && (this.direction != 0 || direction != NavigationItemDirection.Right)) ? items[Mathf.Min(items.Count - 1, (num / itemsPerGroup + 1) * itemsPerGroup - 1)] : items[num / itemsPerGroup * itemsPerGroup]) : items[items.Count - 1 - (items.Count - 1 - num) % itemsPerGroup]) : items[num % itemsPerGroup];
         if (navigationItem.selectable != null)
         {
             return(navigationItem.selectable);
         }
         return(navigationItem.subNavigation.GetSelectableItem(direction));
     }
     if (currentChild != null)
     {
         return(currentChild.GetSelectableItem(direction));
     }
     return(current ?? defaultItem ?? GetComponentInChildren <Selectable>());
 }
 public Selectable GetSelectable(NavigationItemDirection direction)
 {
     if (selectable != null)
     {
         return(selectable);
     }
     return(subNavigation.GetSelectableItem(direction));
 }
 public void Bind(NavigationItemDirection direction, Selectable next)
 {
     if (selectable != null)
     {
         Bind(direction, selectable, next);
     }
     else if (subNavigation != null)
     {
         subNavigation.Bind(direction, next);
     }
 }
Beispiel #5
0
 public void Bind(NavigationItemDirection direction, Selectable next)
 {
     if (items.Count == 0)
     {
         return;
     }
     if ((this.direction == NavigationDirection.Vertical && direction == NavigationItemDirection.Left) || (this.direction == NavigationDirection.Horizontal && direction == NavigationItemDirection.Up))
     {
         for (int i = 0; i < itemsPerGroup; i++)
         {
             if (i < items.Count)
             {
                 items[i].Bind(direction, next);
             }
         }
     }
     else if ((this.direction == NavigationDirection.Vertical && direction == NavigationItemDirection.Right) || (this.direction == NavigationDirection.Horizontal && direction == NavigationItemDirection.Down))
     {
         for (int j = items.Count - itemsPerGroup; j < items.Count; j++)
         {
             if (j >= 0)
             {
                 items[j].Bind(direction, next);
             }
         }
     }
     else if ((this.direction == NavigationDirection.Vertical && direction == NavigationItemDirection.Up) || (this.direction == NavigationDirection.Horizontal && direction == NavigationItemDirection.Left))
     {
         for (int k = 0; k < groupCount; k++)
         {
             if (k * itemsPerGroup < items.Count)
             {
                 items[k * itemsPerGroup].Bind(direction, next);
             }
         }
     }
     else
     {
         for (int l = 0; l < groupCount; l++)
         {
             items[Mathf.Min(items.Count - 1, (l + 1) * itemsPerGroup - 1)].Bind(direction, next);
         }
     }
 }