public static void UpdateFocus() { if (PanelDragger.ResizePrompting) { return; } // if the user is clicking if (InputManager.GetMouseButtonDown(0) || InputManager.GetMouseButtonDown(1)) { int count = UIManager.PanelHolder.transform.childCount; var mousePos = InputManager.MousePosition; bool clickedInAny = false; for (int i = count - 1; i >= 0; i--) { // make sure this is a real recognized panel var transform = UIManager.PanelHolder.transform.GetChild(i); if (!transformToPanelDict.TryGetValue(transform.GetInstanceID(), out UIPanel panel)) { continue; } // check if our mouse is clicking inside the panel var pos = panel.Rect.InverseTransformPoint(mousePos); if (!panel.Enabled || !panel.Rect.rect.Contains(pos)) { continue; } // if this is not the top panel, reorder and invoke the onchanged event if (transform.GetSiblingIndex() != count - 1) { transform.SetAsLastSibling(); OnPanelsReordered?.Invoke(); } // panel was found, break clickedInAny = true; break; } if (!clickedInAny) { OnClickedOutsidePanels?.Invoke(); } } }
internal static void InvokeOnPanelsReordered() => OnPanelsReordered?.Invoke();