private static UnityEngine.Rect WindowRectResizeRight(Vector2 beginningCursorEdgeDistance, Rect windowRectPoints, Vector2 globalCursorPosition, UnityEngine.Rect newWindowRect) { var globalClickPoint = windowRectPoints.Right - beginningCursorEdgeDistance.x; var distance = Mathf.Abs(globalCursorPosition.x - globalClickPoint); //Right Expand if (globalClickPoint > globalCursorPosition.x) { newWindowRect.width -= distance; } //Right Shrink else if (globalClickPoint < globalCursorPosition.x) { newWindowRect.width += distance; } return(newWindowRect); }
private static UnityEngine.Rect WindowRectResizeBottom(Vector2 beginningCursorEdgeDistance, Rect windowRectPoints, Vector2 globalCursorPosition, UnityEngine.Rect newWindowRect) { var globalClickPoint = windowRectPoints.Bottom - beginningCursorEdgeDistance.y; var distance = Mathf.Abs(globalCursorPosition.y - globalClickPoint); //Bottom Expand if (globalClickPoint > globalCursorPosition.y) { newWindowRect.height -= distance; } //Bottom Shrink else if (globalClickPoint < globalCursorPosition.y) { newWindowRect.height += distance; } return(newWindowRect); }
private static UnityEngine.Rect WindowRectResizeLeft(Vector2 beginningCursorEdgeDistance, Rect windowRectPoints, Vector2 globalCursorPosition, UnityEngine.Rect newWindowRect) { var globalClickPoint = windowRectPoints.Left + beginningCursorEdgeDistance.x; var distance = Mathf.Abs(globalCursorPosition.x - globalClickPoint); //Left Expand if (globalClickPoint > globalCursorPosition.x) { if (MaxWindowSize.x == 0) { newWindowRect.x -= distance; newWindowRect.width += distance; } else if (newWindowRect.width < MaxWindowSize.x) { newWindowRect.x -= distance; newWindowRect.width += distance; } if (newWindowRect.width > MaxWindowSize.x) { var difference = newWindowRect.width - MaxWindowSize.x; newWindowRect.x += difference; } } //Left Shrink else if (globalClickPoint < globalCursorPosition.x) { if (newWindowRect.width > MinWindowSize.x) { newWindowRect.x += distance; newWindowRect.width -= distance; } if (newWindowRect.width < MinWindowSize.x) { var difference = MinWindowSize.x - newWindowRect.width; newWindowRect.x -= difference; } } return(newWindowRect); }
private static UnityEngine.Rect WindowRectResizeTop(Vector2 beginningCursorEdgeDistance, Rect windowRectPoints, Vector2 globalCursorPosition, UnityEngine.Rect newWindowRect) { var globalClickPoint = windowRectPoints.Top + beginningCursorEdgeDistance.y; var distance = Mathf.Abs(globalCursorPosition.y - globalClickPoint); //Top Expand if (globalClickPoint > globalCursorPosition.y) { // newWindowRect.y -= distance; // newWindowRect.height += distance; if (MaxWindowSize.y == 0) { newWindowRect.y -= distance; newWindowRect.height += distance; } else if (newWindowRect.height < MaxWindowSize.y) { newWindowRect.y -= distance; newWindowRect.height += distance; } if (newWindowRect.height > MaxWindowSize.y) { var difference = newWindowRect.height - MaxWindowSize.y; newWindowRect.y += difference; } } //Top Shrink else if (globalClickPoint < globalCursorPosition.y) { // newWindowRect.y += distance; // newWindowRect.height -= distance; if (newWindowRect.height > MinWindowSize.y) { newWindowRect.y += distance; newWindowRect.height -= distance; } if (newWindowRect.height < MinWindowSize.y) { var difference = MinWindowSize.y - newWindowRect.height; newWindowRect.y -= difference; } } return(newWindowRect); }