-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (97 loc) · 2.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!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 | CLIMATE BOY</title>
<style>
body,
html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#unity-container {
width: 100%;
height: 100%;
position: relative;
background: black;
overflow: hidden;
}
#unity-canvas {
width: 100%;
height: 100%;
display: block;
}
#unity-loading-bar {
position: absolute;
width: 100%;
height: 10px;
bottom: 10%;
background: gray;
}
#unity-progress-bar-full {
width: 0;
height: 100%;
background: green;
}
#unity-warning {
position: absolute;
top: 10px;
left: 10px;
right: 10px;
padding: 10px;
background: yellow;
display: none;
}
</style>
</head>
<body>
<div id="unity-container">
<canvas id="unity-canvas" tabindex="-1"></canvas>
<div id="unity-loading-bar">
<div id="unity-progress-bar-full"></div>
</div>
<div id="unity-warning"></div>
</div>
<script>
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBarFull = document.querySelector("#unity-progress-bar-full");
var warningBanner = document.querySelector("#unity-warning");
function unityShowBanner(msg, type) {
var div = document.createElement('div');
div.innerHTML = msg;
if (type === 'error') div.style.background = 'red';
if (type === 'warning') div.style.background = 'yellow';
warningBanner.appendChild(div);
warningBanner.style.display = 'block';
}
var config = {
dataUrl: "Build/TEST WEBGL.data.gz",
frameworkUrl: "Build/TEST WEBGL.framework.js.gz",
codeUrl: "Build/TEST WEBGL.wasm.gz",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "CLIMATE BOY",
productVersion: "0.1",
showBanner: unityShowBanner,
};
loadingBar.style.display = "block";
var script = document.createElement("script");
script.src = "Build/TEST WEBGL.loader.js";
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
}).then(() => {
loadingBar.style.display = "none";
}).catch((message) => {
alert(message);
});
};
document.body.appendChild(script);
</script>
</body>
</html>