Skip to content

Commit e6bb06d

Browse files
authored
Merge pull request #226 from davyzhang/master
Avoid hitting test on invalid positions
2 parents 6b17fba + 25b7bcc commit e6bb06d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Assets/Scripts/Core/Stage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,9 @@ void GetHitTarget()
917917
#endif
918918
pos.y = Screen.height - pos.y;
919919
TouchInfo touch = _touches[0];
920-
if (float.IsNaN(pos.x) || float.IsNaN(pos.y) || float.pos.x < 0 || pos.y < 0) // outside of the window
920+
if (float.IsNaN(pos.x) || float.IsNaN(pos.y) || float.IsInfinity(pos.x) || float.IsInfinity(pos.y)) //not a valid position
921+
_touchTarget = this;
922+
else if (pos.x < 0 || pos.y < 0) // outside of the window
921923
_touchTarget = this;
922924
else
923925
_touchTarget = HitTest(pos, true);

0 commit comments

Comments
 (0)