-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
167 lines (149 loc) · 4.26 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
166
167
<!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>
<link rel="stylesheet" href="debug-console.css">
</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 JohannesDeml">
<div id="unity-loading-bar">
<div id="unity-loading-bar-inner"></div>
</div>
</div>
<script src="Build/Feb29Build.loader.js"></script>
<script>
var buildUrl = "Build";
var loaderUrl = buildUrl + "/Feb29Build.loader.js";
var config = {
dataUrl: buildUrl + "/228a4974f65f40e01bbe407077118858.data",
frameworkUrl: buildUrl + "/d9db9b0b7f69fb06ff2361eda600e0b6.js",
codeUrl: buildUrl + "/c90dbd76145a52e0edbee102639fd056.wasm",
streamingAssetsUrl: "StreamingAssets",
companyName: "JohannesDeml",
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; // This variable can be used to access the application with .SendMessage() commands
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>
<!-- Add an html debug console and handle unity rich text styling for both html and browser console-->
<script src="./debug-console.js"></script>
</body>
</html>