/// <summary> /// My black vodoo script, do not use outside /// </summary> /// <param name="ScreenMgr"></param> /// <param name="children"></param> private void UpdateNavigation(ScreenManager ScreenMgr, Transform[] children) { for (int i = 0; i < children.Length; i++) { children[i].gameObject.SetActive(false); } List <Selectable> selectables = new List <Selectable>(); for (int i = 0; i < children.Length; i++) { Transform parent = children[i]; BaseScreen screen = parent.GetComponent <BaseScreen>(); if (!screen.generateNavigation) { continue; } parent.gameObject.SetActive(true); selectables.Clear(); parent.GetComponentsInChildren <Selectable>(selectables); Selectable[] directions = new Selectable[4]; foreach (Selectable selectableUI in selectables) { //Debug.Log("<b>" + parent.name + "</b>." + selectableUI.name, selectableUI); Transform t = selectableUI.transform; directions[0] = FindSelectable(parent, t, selectables, t.rotation * Vector3.up); directions[1] = FindSelectable(parent, t, selectables, t.rotation * Vector3.right); directions[2] = FindSelectable(parent, t, selectables, t.rotation * Vector3.down); directions[3] = FindSelectable(parent, t, selectables, t.rotation * Vector3.left); if (selectableUI is Slider) { Slider.Direction dir = (selectableUI as Slider).direction; if (dir == Slider.Direction.TopToBottom || dir == Slider.Direction.BottomToTop) { directions[0] = directions[2] = null; } else { directions[1] = directions[3] = null; } } selectableUI.navigation = new Navigation() { mode = Navigation.Mode.Explicit, selectOnUp = directions[0], selectOnRight = directions[1], selectOnDown = directions[2], selectOnLeft = directions[3], }; CancelTrigger sctrigger = selectableUI.gameObject.GetComponent <CancelTrigger>(); if (sctrigger == null) { var cancelHandlerAvailable = selectableUI.GetComponent <ICancelHandler>(); if (cancelHandlerAvailable == null) { sctrigger = selectableUI.gameObject.AddComponent <CancelTrigger>(); sctrigger.disableCancelHandler = cancelHandlerAvailable != null; } } } parent.gameObject.SetActive(false); } if (ScreenMgr.defaultScreen != null) { ScreenMgr.defaultScreen.gameObject.SetActive(true); } }