Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed setMargins in unity-webview-2020/unity-webview.js. #846

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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