Skip to content

Commit

Permalink
fixed to consider the device pixel ratio.
Browse files Browse the repository at this point in the history
  • Loading branch information
KojiNakamaru committed Oct 25, 2023
1 parent 1a6b30c commit 951e89b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/Editor/UnityWebViewPostprocessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,14 @@ void CWebViewPlugin_ClearMasks()
void CWebViewPlugin_AddMask(int x, int y, int w, int h)
{
[(UnityView *)UnityGetGLView() addMask:CGRectMake(x, y, x + w, y + h)];
UIView *view = UnityGetGLViewController().view;
CGFloat scale = 1.0f;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
scale = view.window.screen.nativeScale;
} else {
scale = view.contentScaleFactor;
}
[(UnityView *)UnityGetGLView() addMask:CGRectMake(x / scale, y / scale, w / scale, h / scale)];
}
");
File.WriteAllText(path + "/Classes/UI/UnityView.mm", string.Join("\n", lines));
Expand Down

0 comments on commit 951e89b

Please sign in to comment.