mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
Fix UIPanels being broken after resolution changes, better checks on size/position
This commit is contained in:
@ -250,15 +250,9 @@ namespace UnityExplorer.UI.Panels
|
||||
Vector2 diff = (Vector2)mousePos - m_lastDragPosition;
|
||||
m_lastDragPosition = mousePos;
|
||||
|
||||
var pos = Panel.localPosition + (Vector3)diff;
|
||||
Panel.localPosition = Panel.localPosition + (Vector3)diff;
|
||||
|
||||
// Prevent panel going oustide screen bounds
|
||||
var halfW = Screen.width * 0.5f;
|
||||
var halfH = Screen.height * 0.5f;
|
||||
pos.x = Math.Max(-halfW, Math.Min(pos.x, halfW - Panel.rect.width));
|
||||
pos.y = Math.Max(-halfH + Panel.rect.height, Math.Min(pos.y, halfH));
|
||||
|
||||
Panel.localPosition = pos;
|
||||
UIPanel.EnsureValidPosition(Panel);
|
||||
}
|
||||
|
||||
public void OnEndDrag()
|
||||
@ -425,6 +419,9 @@ namespace UnityExplorer.UI.Panels
|
||||
if ((Vector2)mousePos == m_lastResizePos)
|
||||
return;
|
||||
|
||||
if (mousePos.x < 0 || mousePos.y < 0 || mousePos.x > Screen.width || mousePos.y > Screen.height)
|
||||
return;
|
||||
|
||||
m_lastResizePos = mousePos;
|
||||
|
||||
float diffX = (float)((decimal)diff.x / Screen.width);
|
||||
|
Reference in New Issue
Block a user