Skip to content

Commit 37036ed

Browse files
committed
fixed to consider the device pixel ratio.
1 parent 32c2491 commit 37036ed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

plugins/Editor/UnityWebViewPostprocessBuild.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,14 @@ void CWebViewPlugin_ClearMasks()
343343
344344
void CWebViewPlugin_AddMask(int x, int y, int w, int h)
345345
{
346-
[(UnityView *)UnityGetGLView() addMask:CGRectMake(x, y, x + w, y + h)];
346+
UIView *view = UnityGetGLViewController().view;
347+
CGFloat scale = 1.0f;
348+
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
349+
scale = view.window.screen.nativeScale;
350+
} else {
351+
scale = view.contentScaleFactor;
352+
}
353+
[(UnityView *)UnityGetGLView() addMask:CGRectMake(x / scale, y / scale, w / scale, h / scale)];
347354
}
348355
");
349356
File.WriteAllText(path + "/Classes/UI/UnityView.mm", string.Join("\n", lines));

0 commit comments

Comments
 (0)