Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
seleb committed Jun 9, 2018
1 parent 034005f commit f73d371
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions WebGLTemplates/BetterMinimal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,70 @@
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%");
var scaleToFit;
try{
try {
scaleToFit = !!JSON.parse("%UNITY_CUSTOM_SCALE_TO_FIT%");
}catch(e){
} catch(e) {
scaleToFit = true;
}
window.onresize = function(){
window.onresize = function() {
var canvas = gameInstance.Module.canvas;
var container = gameInstance.container;
var w;
var h;

if(scaleToFit){
if (scaleToFit) {
w = window.innerWidth;
h = window.innerHeight;

var r = %UNITY_HEIGHT%/%UNITY_WIDTH%;
var r = %UNITY_HEIGHT% / %UNITY_WIDTH%;

if(w * r > window.innerHeight){
if (w * r > window.innerHeight) {
w = Math.min(w, Math.ceil(h / r));
}
h = Math.floor(w * r);
}else{
w=%UNITY_WIDTH%;
h=%UNITY_HEIGHT%;
} else {
w = %UNITY_WIDTH%;
h = %UNITY_HEIGHT%;
}

container.style.width = canvas.style.width = w + "px";
container.style.height = canvas.style.height = h + "px";
container.style.top = Math.floor((window.innerHeight - h)/2) + "px";
container.style.left = Math.floor((window.innerWidth - w)/2) + "px";
container.style.top = Math.floor((window.innerHeight - h) / 2) + "px";
container.style.left = Math.floor((window.innerWidth - w) / 2) + "px";
}
</script>
<style>
html,body{
html,
body {
background: #000;
background: %UNITY_CUSTOM_BACKGROUND%;
width: 100%;
height: 100%;
overflow:visible;
padding:0;
margin:0;
overflow: visible;
padding: 0;
margin: 0;
}
div#gameContainer{

div#gameContainer {
background: transparent!important;
position: absolute;
}
div#gameContainer canvas{

div#gameContainer canvas {
position: absolute;
image-rendering: optimizeSpeed;
image-rendering: -webkit-crisp-edges;
image-rendering: -webkit-crisp-edges;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
image-rendering: optimize-contrast;
image-rendering: pixelated;
-ms-interpolation-mode: nearest-neighbor;
}
</style>
</head>

<body onload="window.onresize();">
<div id="gameContainer"></div>
</body>
Expand Down

0 comments on commit f73d371

Please sign in to comment.