From c8f3a7f43076d3d06fd18d3af424068e358d40bd Mon Sep 17 00:00:00 2001 From: Sinai Date: Fri, 16 Apr 2021 23:59:41 +1000 Subject: [PATCH] Fix min resize --- src/UI/Utility/PanelDragger.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/UI/Utility/PanelDragger.cs b/src/UI/Utility/PanelDragger.cs index 334952a..9fa450f 100644 --- a/src/UI/Utility/PanelDragger.cs +++ b/src/UI/Utility/PanelDragger.cs @@ -34,7 +34,7 @@ namespace UnityExplorer.UI.Utility public GameObject m_resizeCursorObj; - internal readonly Vector2 minResize = new Vector2(400, 400); + internal readonly Vector2 minResize = new Vector2(200, 50); private bool WasResizing { get; set; } private ResizeTypes m_currentResizeType = ResizeTypes.NONE; @@ -332,21 +332,21 @@ namespace UnityExplorer.UI.Utility else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom)) anchorMin.y -= diffY; + var prevMin = Panel.anchorMin; + var prevMax = Panel.anchorMax; + Panel.anchorMin = new Vector2(anchorMin.x, anchorMin.y); Panel.anchorMax = new Vector2(anchorMax.x, anchorMax.y); - var newWidth = (anchorMax.x - anchorMin.x) * Screen.width; - var newHeight = (anchorMax.y - anchorMin.y) * Screen.height; - - if (newWidth >= minResize.x) + if (Panel.rect.width < minResize.x) { - Panel.anchorMin = new Vector2(anchorMin.x, Panel.anchorMin.y); - Panel.anchorMax = new Vector2(anchorMax.x, Panel.anchorMax.y); + Panel.anchorMin = new Vector2(prevMin.x, Panel.anchorMin.y); + Panel.anchorMax = new Vector2(prevMax.x, Panel.anchorMax.y); } - if (newHeight >= minResize.y) + if (Panel.rect.height < minResize.y) { - Panel.anchorMin = new Vector2(Panel.anchorMin.x, anchorMin.y); - Panel.anchorMax = new Vector2(Panel.anchorMax.x, anchorMax.y); + Panel.anchorMin = new Vector2(Panel.anchorMin.x, prevMin.y); + Panel.anchorMax = new Vector2(Panel.anchorMax.x, prevMax.y); } }