-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
138 lines (127 loc) · 4.35 KB
/
index.html
File metadata and controls
138 lines (127 loc) · 4.35 KB
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
<!DOCTYPE html>
<html lang="en-us">
<head>
<base href="https://cdn.jsdelivr.net/gh/genizy/web-port@main/milkman-karlson/">
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Unity WebGL Player | Milkman Karlson</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<style>
* {
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
}
body {
background: #000;
position: fixed;
width: 100%;
height: 100%;
}
.webgl-content {
position: absolute;
width: 100%;
height: 100%;
}
#unityContainer {
position: absolute;
width: 100%;
height: 100%;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
padding: 10px 0;
background: rgba(0, 0, 0, 0.5);
z-index: 100;
}
.fullscreen {
cursor: pointer;
display: inline-block;
width: 24px;
height: 24px;
background: url('TemplateData/fullscreen.png') no-repeat center;
}
</style>
<script src="TemplateData/UnityProgress.js"></script>
<script src="Build/UnityLoader.js"></script>
<script>
function mergeFiles(fileParts) {
return new Promise((resolve, reject) => {
let buffers = [];
function fetchPart(index) {
if (index >= fileParts.length) {
let mergedBlob = new Blob(buffers);
let mergedFileUrl = URL.createObjectURL(mergedBlob);
resolve(mergedFileUrl);
return;
}
fetch(fileParts[index]).then((response) => response.arrayBuffer()).then((data) => {
buffers.push(data);
fetchPart(index + 1);
}).catch(reject);
}
fetchPart(0);
});
}
function getParts(file, start, end) {
let parts = [];
for (let i = start; i <= end; i++) {
parts.push(file + ".part" + i);
}
return parts;
}
function resizeUnityContainer() {
var container = document.getElementById("unityContainer");
container.style.width = window.innerWidth + "px";
container.style.height = window.innerHeight + "px";
}
Promise.all([
mergeFiles(getParts("Build/MILKMAN.data.unityweb", 1, 5))
]).then(([dataUrl]) => {
window.dataUrll = dataUrl;
var json = {
"companyName": "Dani",
"productName": "MilkmanKarlson",
"productVersion": "0.2",
"dataUrl": "MILKMAN.data.unityweb",
"wasmCodeUrl": "MILKMAN.wasm.code.unityweb",
"wasmFrameworkUrl": "MILKMAN.wasm.framework.unityweb",
"graphicsAPI": ["WebGL 2.0","WebGL 1.0"],
"webglContextAttributes": {"preserveDrawingBuffer": false},
"backgroundUrl": "MILKMAN.jpg",
"splashScreenStyle": "Dark",
"backgroundColor": "#FFFFFF",
"developmentBuild": false,
"multithreading": false,
"unityVersion": "2019.2.13f1"
};
let blob = new Blob([JSON.stringify(json)], {
type: 'application/json'
});
let blobUrl = URL.createObjectURL(blob);
window.addEventListener('resize', resizeUnityContainer);
UnityLoader.instantiate("unityContainer", json, {
onProgress: UnityProgress,
url: blobUrl,
Module: {
onRuntimeInitialized: function () {
resizeUnityContainer();
document.querySelector("#loading-text").remove();
}
}
});
});
</script>
</head>
<body>
<div class="webgl-content">
<div id="loading-text" style="color: white; font-size: 48px; font-family: cursive; text-align: center; margin-top: 20px;">LOADING...</div>
<div id="unityContainer"></div>
</div>
</body>
</html>