diff --git a/plugins/WebGLTemplates/unity-webview-2020/unity-webview.js b/plugins/WebGLTemplates/unity-webview-2020/unity-webview.js index 6c8349a0..2a82ce5f 100644 --- a/plugins/WebGLTemplates/unity-webview-2020/unity-webview.js +++ b/plugins/WebGLTemplates/unity-webview-2020/unity-webview.js @@ -53,13 +53,16 @@ var unityWebView = setMargins: function (name, left, top, right, bottom) { var container = $('#unity-container'); - var width = container.width(); - var height = container.height(); + var w0 = container.width() * window.devicePixelRatio; + var h0 = container.height() * window.devicePixelRatio; + var canvas = $('#unity-canvas'); + var w1 = canvas.attr('width'); + var h1 = canvas.attr('height'); - var lp = left / width * 100; - var tp = top / height * 100; - var wp = (width - left - right) / width * 100; - var hp = (height - top - bottom) / height * 100; + var lp = left / w0 * 100; + var tp = top / h0 * 100; + var wp = (w1 - left - right) / w0 * 100; + var hp = (h1 - top - bottom) / h0 * 100; this.iframe(name) .css('left', lp + '%')