From cd7f395a077842eccb54c5f555373a3eb7cac6ef Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sat, 16 Mar 2019 17:08:33 +0900 Subject: [PATCH] fix #43; Pixels out of range may be read by raycaster --- .../Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs index 644fec7..50e970f 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs @@ -239,8 +239,8 @@ namespace Coffee.UIExtensions return true; } - int x = (int)(softMaskBuffer.width * sp.x / Screen.width); - int y = (int)(softMaskBuffer.height * sp.y / Screen.height); + int x = (int)((softMaskBuffer.width - 1) * Mathf.Clamp01(sp.x / Screen.width)); + int y = (int)((softMaskBuffer.height - 1) * Mathf.Clamp01(sp.y / Screen.height)); return 0.5f < GetPixelValue(x, y, interactions); }