From 97a82c1661cf19c1fed864f903ac2362fd6f8cd7 Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Sun, 23 Jan 2022 23:08:34 +1100 Subject: [PATCH] Make sure mouse is in target display for resize/dragging/panel operations --- src/UI/DisplayManager.cs | 1 + src/UI/Panels/PanelDragger.cs | 3 +++ src/UI/Panels/UIPanel.cs | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/UI/DisplayManager.cs b/src/UI/DisplayManager.cs index ee5455d..e27385f 100644 --- a/src/UI/DisplayManager.cs +++ b/src/UI/DisplayManager.cs @@ -19,6 +19,7 @@ namespace UnityExplorer.UI public static int Height => ActiveDisplay.renderingHeight; public static Vector3 MousePosition => Display.RelativeMouseAt(InputManager.MousePosition); + public static bool MouseInTargetDisplay => MousePosition.z == ActiveDisplayIndex; private static Camera canvasCamera; diff --git a/src/UI/Panels/PanelDragger.cs b/src/UI/Panels/PanelDragger.cs index 0ce5700..f3e226e 100644 --- a/src/UI/Panels/PanelDragger.cs +++ b/src/UI/Panels/PanelDragger.cs @@ -67,6 +67,9 @@ namespace UnityExplorer.UI.Panels public static void UpdateInstances() { + if (!DisplayManager.MouseInTargetDisplay) + return; + if (!resizeCursorObj) CreateCursorUI(); diff --git a/src/UI/Panels/UIPanel.cs b/src/UI/Panels/UIPanel.cs index 1139203..5e54afc 100644 --- a/src/UI/Panels/UIPanel.cs +++ b/src/UI/Panels/UIPanel.cs @@ -33,7 +33,8 @@ namespace UnityExplorer.UI.Panels return; // if the user is clicking - if (InputManager.GetMouseButtonDown(0) || InputManager.GetMouseButtonDown(1)) + if (DisplayManager.MouseInTargetDisplay + && (InputManager.GetMouseButtonDown(0) || InputManager.GetMouseButtonDown(1))) { int count = UIManager.PanelHolder.transform.childCount; var mousePos = DisplayManager.MousePosition;