Skip to content

Instantly share code, notes, and snippets.

@lucasmontec
Created May 5, 2018 20:55
Show Gist options
  • Save lucasmontec/ad257eacee9173ede2d5133168d604b4 to your computer and use it in GitHub Desktop.
Save lucasmontec/ad257eacee9173ede2d5133168d604b4 to your computer and use it in GitHub Desktop.
Unity WebGL 16:9 responsive canvas - you can change the ratio by changing css padding
/* The style: */
#game:before {
display: block;
content: " ";
width: 100%;
padding-top: 56.25%;
}
#game {
width: 60%;
}
#game > canvas {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
/* this is applied to the canvas where the unity game is spawned: <div id="game"></div> - var gameInstance = UnityLoader.instantiate("game", "Build/v 0.3.0.json");*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment