Skip to content

Instantly share code, notes, and snippets.

@korinVR
Last active January 15, 2019 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korinVR/45d7f2fc0816a5c6e32a20b8d93e0255 to your computer and use it in GitHub Desktop.
Save korinVR/45d7f2fc0816a5c6e32a20b8d93e0255 to your computer and use it in GitHub Desktop.
Unity の WebGL 出力をブラウザ一杯に表示するテンプレート
<!-- 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