Skip to content

Commit

Permalink
- overlay canvas support
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipVajgand committed Apr 26, 2018
1 parent c7f05e7 commit 1bb31c5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Unity/Assets/Scripts/UnityMobileInput/MobileInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,14 @@ Rect GetScreenRectFromRectTransform (RectTransform rect) {
float yMin = float.PositiveInfinity;
float yMax = float.NegativeInfinity;
for (int i = 0; i < 4; i++) {
Vector3 screenCoord = RectTransformUtility.WorldToScreenPoint (Camera.main, corners[i]);
Vector3 screenCoord;
if (rect.GetCanvas().GetComponent<Canvas>().renderMode == RenderMode.ScreenSpaceOverlay)
{
screenCoord = corners[i];
} else
{
screenCoord = RectTransformUtility.WorldToScreenPoint(Camera.main, corners[i]);
}
if (screenCoord.x < xMin)
xMin = screenCoord.x;
if (screenCoord.x > xMax)
Expand Down Expand Up @@ -565,4 +572,4 @@ private void UpdateForceKeyeventForAndroid () {
#endif
}

}
}

0 comments on commit 1bb31c5

Please sign in to comment.