Created
May 5, 2018 20:55
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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