Skip to content

Commit

Permalink
Merge pull request #846 from gree/fix/2020-webgl-setmargin
Browse files Browse the repository at this point in the history
fixed setMargins in unity-webview-2020/unity-webview.js.
  • Loading branch information
KojiNakamaru authored Oct 4, 2022
2 parents e2ee37a + b9dd809 commit fbb108c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions plugins/WebGLTemplates/unity-webview-2020/unity-webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '%')
Expand Down

0 comments on commit fbb108c

Please sign in to comment.