public void EnableAutoNav() { _autoNavigation = new AutoNavigation(_map); _autoNavigation.PanToEvent += _autoNavigation_PanToEvent; _autoNavigation.Start(); }
private void LateUpdate() { if (selectLastFocused && EventSystem.current.currentSelectedGameObject != null) { Selectable component = EventSystem.current.currentSelectedGameObject.GetComponent <Selectable>(); if (component != null && current != component) { for (int i = 0; i < items.Count; i++) { if (items[i].selectable == component) { current = component; currentChild = null; invalid = true; AutoNavigation componentInParent = base.transform.parent.GetComponentInParent <AutoNavigation>(); if (componentInParent != null) { componentInParent.ChildSelected(this); } break; } } } } if (invalid) { Rebuild(); invalid = false; } }
public void DisableAutoNav() { if (_autoNavigation != null) { _autoNavigation.Stop(); _autoNavigation.PanToEvent -= _autoNavigation_PanToEvent; _autoNavigation = null; } }
private void Awake() { m_arButtonList = new UpdatePlayerStatus[MaxPlayerCount]; for (int i = 0; i < MaxPlayerCount; i++) { AddButton(); } m_arButtonList = base.gameObject.transform.GetComponentsInChildren <UpdatePlayerStatus>(includeInactive: true); UpdatePlayerStatus[] arButtonList = m_arButtonList; foreach (UpdatePlayerStatus updatePlayerStatus in arButtonList) { updatePlayerStatus.m_DarkBackground = m_DarkBackground; } m_NavigationObject = GetComponent <AutoNavigation>(); m_bIsGridList = GetComponent <GridCellScaler>(); m_NavigationObject.fixedItemsPerGroup = m_bIsGridList; m_NavigationObject.itemsPerGroup = (m_bIsGridList ? 4 : 0); }
private void Rebuild() { if (current != null && !current.isActiveAndEnabled) { current = null; } items.Clear(); CollectChildrenRecursive(base.transform); itemsPerGroup = ((!fixedItemsPerGroup) ? ((items.Count + groupCount - 1) / groupCount) : itemsPerGroup); if (items.Count != 0) { for (int i = 0; i < groupCount; i++) { int num = i * itemsPerGroup; int num2 = Mathf.Min((i + 1) * itemsPerGroup, items.Count); for (int j = num + 1; j < num2; j++) { Link(items[j - 1], items[j]); } if (num2 - 1 > 0 && num2 - 1 < items.Count) { Link(items[num2 - 1], items[num]); } } for (int k = 1; k < groupCount; k++) { int num3 = k * itemsPerGroup; int num4 = (k + 1) * itemsPerGroup - 1; for (int num5 = num4; num5 >= num3; num5--) { int index = Mathf.Min(num5, items.Count - 1); Link(items[num5 - itemsPerGroup], items[index], (direction == NavigationDirection.Horizontal) ? NavigationDirection.Vertical : NavigationDirection.Horizontal); } } } AutoNavigation componentInParent = base.transform.parent.GetComponentInParent <AutoNavigation>(); if (componentInParent != null) { componentInParent.Rebuild(); } }
public override void OnLostFocus() { base.OnLostFocus(); for (int i = 0; i < channelButtons.Count; i++) { Object.Destroy(channelButtons[i].gameObject); } channelButtons.Clear(); if (colorsContainer != null) { AutoNavigation component = colorsContainer.GetComponent <AutoNavigation>(); if (component != null) { component.ClearCurrent(); } } for (int j = 0; j < colorButtons.Count; j++) { Object.Destroy(colorButtons[j].gameObject); } colorButtons.Clear(); }
private void CollectChildrenRecursive(Transform root) { for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (!child.gameObject.activeInHierarchy) { continue; } Selectable selectable = child.GetComponent <Selectable>(); if (ignoreObjects != null && ignoreObjects.Contains(selectable)) { selectable = null; } if (selectable != null) { items.Add(new NavigationItem { selectable = selectable }); continue; } AutoNavigation component = child.GetComponent <AutoNavigation>(); if (component != null && component.GetComponentInChildren <Selectable>() != null) { items.Add(new NavigationItem { subNavigation = component }); } else { CollectChildrenRecursive(child); } } }
private void ChildSelected(AutoNavigation child) { currentChild = child; current = null; invalid = true; }
public void ClearCurrent() { current = null; currentChild = null; }