Browse Source

Fixed Page rect clipping to screen rect.

Rect is now clipped rather than offset onto the visible screen area.
master
chrisgregan 11 years ago
parent
commit
1375bc9b23
  1. 11
      Assets/Fungus/Scripts/Page.cs

11
Assets/Fungus/Scripts/Page.cs

@ -442,12 +442,11 @@ namespace Fungus
Rect FitRectToScreen(Rect rect)
{
Rect fittedRect = new Rect();
fittedRect.width = Mathf.Min(rect.width, Screen.width);
fittedRect.height = Mathf.Min(rect.height, Screen.height);
fittedRect.x = Mathf.Min(rect.x, Screen.width - rect.width);
fittedRect.y = Mathf.Min(rect.y, Screen.height - rect.height);
fittedRect.x = Mathf.Max(0, fittedRect.x);
fittedRect.y = Mathf.Max(0, fittedRect.y);
fittedRect.xMax = Mathf.Min(rect.xMax, Screen.width);
fittedRect.xMin = Mathf.Max(rect.xMin, 0);
fittedRect.yMax = Mathf.Min(rect.yMax, Screen.height);
fittedRect.yMin = Mathf.Max(rect.yMin, 0);
return fittedRect;
}

Loading…
Cancel
Save