From b5c69fc1eac228151f9f001e42dd285b2362c4a3 Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Sun, 13 Mar 2022 02:59:52 +1100 Subject: [PATCH] Fix UI mouse inspector results panel not always coming to front --- src/Inspectors/MouseInspectors/UiInspector.cs | 8 +++++++ src/UI/Panels/UIPanel.cs | 22 +++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Inspectors/MouseInspectors/UiInspector.cs b/src/Inspectors/MouseInspectors/UiInspector.cs index 305add2..ff12f38 100644 --- a/src/Inspectors/MouseInspectors/UiInspector.cs +++ b/src/Inspectors/MouseInspectors/UiInspector.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,6 +9,7 @@ using UnityEngine.UI; using UnityExplorer.UI; using UnityExplorer.UI.Panels; using UniverseLib; +using UniverseLib.Input; namespace UnityExplorer.Inspectors.MouseInspectors { @@ -38,6 +40,12 @@ namespace UnityExplorer.Inspectors.MouseInspectors { LastHitObjects.Clear(); LastHitObjects.AddRange(currentHitObjects); + RuntimeHelper.StartCoroutine(SetPanelActiveCoro()); + } + + IEnumerator SetPanelActiveCoro() + { + yield return null; var panel = UIManager.GetPanel(UIManager.Panels.UIInspectorResults); panel.SetActive(true); panel.ShowResults(); diff --git a/src/UI/Panels/UIPanel.cs b/src/UI/Panels/UIPanel.cs index 3f71576..15cc40d 100644 --- a/src/UI/Panels/UIPanel.cs +++ b/src/UI/Panels/UIPanel.cs @@ -108,18 +108,18 @@ namespace UnityExplorer.UI.Panels public override void SetActive(bool active) { - if (this.Enabled == active) - return; - - base.SetActive(active); - - if (!ApplyingSaveData) - SaveInternalData(); - - if (NavButtonWanted) + if (this.Enabled != active) { - var color = active ? UniversalUI.EnabledButtonColor : UniversalUI.DisabledButtonColor; - RuntimeHelper.SetColorBlock(NavButton.Component, color, color * 1.2f); + base.SetActive(active); + + if (!ApplyingSaveData) + SaveInternalData(); + + if (NavButtonWanted) + { + var color = active ? UniversalUI.EnabledButtonColor : UniversalUI.DisabledButtonColor; + RuntimeHelper.SetColorBlock(NavButton.Component, color, color * 1.2f); + } } if (!active)