Last active
January 15, 2019 13:50
-
-
Save korinVR/45d7f2fc0816a5c6e32a20b8d93e0255 to your computer and use it in GitHub Desktop.
Unity の WebGL 出力をブラウザ一杯に表示するテンプレート
This file contains 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
<!-- Assets/WebGLTemplates/FullWindow あたりに格納して Player Settings で選択 --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>%UNITY_WEB_NAME%</title> | |
<script src="%UNITY_WEBGL_LOADER_URL%"></script> | |
<script> | |
const gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%"); | |
const onResize = () => { | |
const container = document.getElementById('gameContainer'); | |
const w = container.clientWidth; | |
const h = container.clientHeight; | |
const canvas = document.getElementById('#canvas'); | |
canvas.width = w; | |
canvas.height = h; | |
} | |
window.addEventListener('resize', onResize); | |
</script> | |
<style> | |
html { | |
height: 100%; | |
} | |
body { | |
margin: 0; | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
} | |
#gameContainer { | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="gameContainer"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment