1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <!DOCTYPE html>
- <html lang="en-us">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Unity WebGL Player | meta</title>
- <style>
- html,
- body {
- width: 100%;
- height: 100%;
- margin: 0;
- padding: 0;
- }
- </style>
- </head>
- <body style="text-align: center">
- <canvas id="unity-canvas"></canvas>
- <script src="Build/dist.loader.js"></script>
- <script>
- var myGameInstance = null;
- createUnityInstance(document.querySelector("#unity-canvas"), {
- dataUrl: "Build/dist.data",
- frameworkUrl: "Build/dist.framework.js",
- codeUrl: "Build/dist.wasm",
- streamingAssetsUrl: "StreamingAssets",
- companyName: "DefaultCompany",
- productName: "meta",
- productVersion: "0.1",
- // matchWebGLToCanvasSize: false, // Uncomment this to separately control WebGL canvas render size and DOMelement size.
- // devicePixelRatio: 1, // Uncomment this to override low DPI rendering on high DPI displays.
- }, (progress) => {}).then((unityInstance) => {
- myGameInstance = unityInstance;
- });
- window.onload = function () {
- Reset();
- }
- window.onresize = function () {
- Reset();
- }
- function Reset() {
- var canvas = document.querySelector("#unity-canvas");
- canvas.height = document.body.clientHeight;
- canvas.width = document.body.clientWidth;
- }
- function send(obj) {
- myGameInstance.SendMessage('Canvas', 'SetScene', obj);
- }
- window.addEventListener('message', function (e) { // 监听 message 事件
- if(e.data.type){
- send(e.data.type);
- }
- });
- </script>
- </body>
- </html>
|