Created
April 28, 2022 14:19
-
-
Save iinfin/165387355a116725d793774a7d2f4ddc to your computer and use it in GitHub Desktop.
unity-webgl-template
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
| <!-- https://docs.unity3d.com/Manual/webgl-templates.html --> | |
| <!DOCTYPE html> | |
| <html lang="en-us"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <title>{{{ PRODUCT_NAME }}}</title> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css/normalize.min.css" /> | |
| <style> | |
| html, | |
| body { | |
| margin: 0; | |
| padding: 0; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100vw; | |
| height: 100vh; | |
| overflow: hidden; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <canvas id="unity-canvas"></canvas> | |
| <script src="Build/{{{ LOADER_FILENAME }}}"></script> | |
| <script> | |
| const canvas = document.getElementById('unity-canvas'); | |
| function onResize() { | |
| let width = window.innerWidth; | |
| let height = window.innerHeight; | |
| canvas.width = width; | |
| canvas.height = height; | |
| canvas.style.width = width + 'px'; | |
| canvas.style.height = height + 'px'; | |
| } | |
| window.addEventListener('resize', onResize); | |
| onResize(); | |
| createUnityInstance(canvas, { | |
| dataUrl: `Build/{{{ DATA_FILENAME }}}`, | |
| frameworkUrl: `Build/{{{ FRAMEWORK_FILENAME }}}`, | |
| codeUrl: `Build/{{{ CODE_FILENAME }}}`, | |
| streamingAssetsUrl: `StreamingAssets`, | |
| companyName: `{{{ COMPANY_NAME }}}`, | |
| productName: `{{{ PRODUCT_NAME }}}`, | |
| productVersion: `{{{ PRODUCT_VERSION }}}`, | |
| matchWebGLToCanvasSize: false, | |
| devicePixelRatio: 1, | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment