fix: Raycast coordinates are incorrect

Close #52
pull/87/head
mob-sakai 2020-01-28 19:23:10 +09:00
parent f5bd6003a8
commit 0f74fb8255
1 changed files with 6 additions and 1 deletions

View File

@ -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)