feat: basic window resizing
This commit is contained in:
parent
438b16fc6e
commit
ce692af862
18 changed files with 324 additions and 74 deletions
40
Packages/AppWindowUtility/Runtime/ResizeHelper.cs
Normal file
40
Packages/AppWindowUtility/Runtime/ResizeHelper.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SatorImaging.AppWindowUtility {
|
||||
public static class ResizeHelper {
|
||||
public static Vector2 GetDirection(Vector2 mousePosition, Vector2 screenSize) {
|
||||
float widthPercentage = mousePosition.x / screenSize.x;
|
||||
float heightPercentage = mousePosition.y / screenSize.y;
|
||||
|
||||
const float marginHeightPercentage = 30f / 1920f;
|
||||
const float marginWidthPercentage = 30f / 1280f;
|
||||
|
||||
if (widthPercentage < marginWidthPercentage) {
|
||||
if (heightPercentage > 1 - marginHeightPercentage)
|
||||
return new Vector2(-1, 1);
|
||||
if (heightPercentage < marginHeightPercentage)
|
||||
return new Vector2(-1, -1);
|
||||
|
||||
return new Vector2(-1, 0);
|
||||
}
|
||||
|
||||
if (widthPercentage > 1 - marginWidthPercentage) {
|
||||
if (heightPercentage > 1 - marginHeightPercentage)
|
||||
return new Vector2(1, 1);
|
||||
if (heightPercentage < marginHeightPercentage)
|
||||
return new Vector2(1, -1);
|
||||
|
||||
return new Vector2(1, 0);
|
||||
}
|
||||
|
||||
if (heightPercentage > 1 - marginHeightPercentage)
|
||||
return new Vector2(0, 1);
|
||||
|
||||
if (heightPercentage < marginHeightPercentage)
|
||||
return new Vector2(0, -1);
|
||||
|
||||
return Vector2.zero;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue