From 99bceaf6192b86f674976b79867c400d6776c9a8 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 28 Jan 2020 19:23:10 +0900 Subject: [PATCH] fix: Raycast coordinates are incorrect Close #52 --- .../UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs index cf4530d..a65fbfa 100755 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMask.cs @@ -45,6 +45,8 @@ namespace Coffee.UIExtensions new Color(1, 1, 1, 0), }; + static bool s_UVStartsAtTop; + //################################ // Serialize Members. @@ -259,7 +261,9 @@ namespace Coffee.UIExtensions } int x = (int)((softMaskBuffer.width - 1) * Mathf.Clamp01(sp.x / Screen.width)); - int y = (int)((softMaskBuffer.height - 1) * Mathf.Clamp01(sp.y / Screen.height)); + int y = s_UVStartsAtTop + ? (int)((softMaskBuffer.height - 1) * Mathf.Clamp01(sp.y / Screen.height)) + : (int)((softMaskBuffer.height - 1) * (1 - Mathf.Clamp01(sp.y / Screen.height))); return 0.5f < GetPixelValue(x, y, interactions); } @@ -282,6 +286,7 @@ namespace Coffee.UIExtensions // Register. if (s_ActiveSoftMasks.Count == 0) { + s_UVStartsAtTop = SystemInfo.graphicsUVStartsAtTop; Canvas.willRenderCanvases += UpdateMaskTextures; if (s_StencilCompId == 0)