-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
165 lines (148 loc) · 4.09 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebLoadingTest</title>
<style>
* {
padding: 0;
margin: 0;
}
html {
/* fix mobile viewport menu bar on iOS */
height: -webkit-fill-available;
}
body {
height: 100%;
/* fix mobile viewport menu bar on iOS */
height: -webkit-fill-available;
width: 100%;
text-align: center;
}
#unity-container {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: #222;
}
/* Default values, might be overwritten by aspect ratio media queries */
#unity-canvas {
width: 100%;
height: 100%;
background-color: #fff;
}
@media (min-aspect-ratio: 3/1) {
#unity-canvas {
width: auto;
height: 100%;
aspect-ratio: 3/1;
}
}
@media (max-aspect-ratio: 1/2) {
#unity-canvas {
width: 100%;
height: auto;
aspect-ratio: 1/2;
}
}
#unity-loading-container {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 40px;
opacity: 1;
visibility: visible;
transition: 800ms linear;
}
#unity-loading-container.finished {
opacity: 0;
visibility: collapse;
}
#unity-loading-container .logo {
width: 15%;
height: 15%;
}
#unity-loading-bar {
position: relative;
width: 40%;
height: 10px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 10px;
}
#unity-loading-bar-inner {
position: absolute;
left: 0%;
top: 0%;
width: 1%;
height: 100%;
background-color: #ccc;
border-radius: 10px;
transition: 400ms linear;
}
</style>
</head>
<body>
<div id="unity-container">
<canvas id="unity-canvas"></canvas>
</div>
<div id="unity-loading-container">
<img src="logo.svg" class="logo" alt="Logo Snappy">
<div id="unity-loading-bar">
<div id="unity-loading-bar-inner"></div>
</div>
</div>
<script src="Build/Build3.loader.js"></script>
<script>
var buildUrl = "Build";
var loaderUrl = buildUrl + "/Build3.loader.js";
var config = {
dataUrl: buildUrl + "/718e6b20f243a8b173e027a6506e826c.data.gz",
frameworkUrl: buildUrl + "/574a8387b3e48986bfea8d0d1d278029.js.gz",
codeUrl: buildUrl + "/3bb535c874521b10708894b18a430f06.wasm.gz",
streamingAssetsUrl: "StreamingAssets",
companyName: "Snappy",
productName: "WebLoadingTest",
productVersion: "1.0.0",
};
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if(isMobile) {
// Define a maximum pixel ratio for mobile to avoid rendering at too high resolutions
const maxPixelRatioMobile = 2.0;
config.devicePixelRatio = Math.min(window.devicePixelRatio, maxPixelRatioMobile);
}
var canvas = document.querySelector("#unity-canvas");
var loadingContainer = document.querySelector("#unity-loading-container");
var loadingBar = document.querySelector("#unity-loading-bar-inner");
var unityGame;
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = function() {
createUnityInstance(canvas, config, function(progress) {
loadingBar.style.width = 100 * progress + "%";
}).then(function(unityInstance) {
unityGame = unityInstance;
loadingContainer.classList.add("finished");
}).catch(function(message) {
alert(message);
});
};
document.body.appendChild(script);
</script>
<!-- Parse Unity rich text to render stylized browser console logs -->
<script src="./pretty-console.js"></script>
</body>
</html>