Spaces:
Running
Running
Add Unity WebGL build files
Browse files- index.html +75 -15
index.html
CHANGED
@@ -25,25 +25,85 @@
|
|
25 |
</div>
|
26 |
<div id="unity-fullscreen-button" style="display: none;"></div>
|
27 |
<script>
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
-
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
</body>
|
48 |
|
49 |
</html>
|
|
|
25 |
</div>
|
26 |
<div id="unity-fullscreen-button" style="display: none;"></div>
|
27 |
<script>
|
28 |
+
const hideFullScreenButton = "";
|
29 |
+
const buildUrl = "Build";
|
30 |
+
const loaderUrl = buildUrl + "/Retro-to-3D.loader.js";
|
31 |
+
const config = {
|
32 |
+
dataUrl: buildUrl + "/Retro-to-3D.data",
|
33 |
+
frameworkUrl: buildUrl + "/Retro-to-3D.framework.js",
|
34 |
+
codeUrl: buildUrl + "/Retro-to-3D.wasm",
|
35 |
+
streamingAssetsUrl: "StreamingAssets",
|
36 |
+
companyName: "ilumine AI",
|
37 |
+
productName: "Pj - 2D-to-3D",
|
38 |
+
productVersion: "0.1.12",
|
39 |
+
};
|
40 |
|
41 |
+
const container = document.querySelector("#unity-container");
|
42 |
+
const canvas = document.querySelector("#unity-canvas");
|
43 |
+
const loadingCover = document.querySelector("#loading-cover");
|
44 |
+
const progressBarEmpty = document.querySelector("#unity-progress-bar-empty");
|
45 |
+
const progressBarFull = document.querySelector("#unity-progress-bar-full");
|
46 |
+
const fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
47 |
+
const spinner = document.querySelector('.spinner');
|
48 |
+
|
49 |
+
const canFullscreen = (function () {
|
50 |
+
for (const key of [
|
51 |
+
'exitFullscreen',
|
52 |
+
'webkitExitFullscreen',
|
53 |
+
'webkitCancelFullScreen',
|
54 |
+
'mozCancelFullScreen',
|
55 |
+
'msExitFullscreen',
|
56 |
+
]) {
|
57 |
+
if (key in document) {
|
58 |
+
return true;
|
59 |
}
|
60 |
+
}
|
61 |
+
return false;
|
62 |
+
}());
|
63 |
+
|
64 |
+
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
65 |
+
container.className = "unity-mobile";
|
66 |
+
config.devicePixelRatio = 1;
|
67 |
}
|
68 |
+
loadingCover.style.display = "";
|
69 |
|
70 |
+
const script = document.createElement("script");
|
71 |
+
script.src = loaderUrl;
|
72 |
+
script.onload = () => {
|
73 |
+
createUnityInstance(canvas, config, (progress) => {
|
74 |
+
spinner.style.display = "none";
|
75 |
+
progressBarEmpty.style.display = "";
|
76 |
+
progressBarFull.style.width = `${100 * progress}%`;
|
77 |
+
}).then((unityInstance) => {
|
78 |
+
loadingCover.style.display = "none";
|
79 |
+
if (canFullscreen) {
|
80 |
+
if (!hideFullScreenButton) {
|
81 |
+
fullscreenButton.style.display = "";
|
82 |
+
}
|
83 |
+
fullscreenButton.onclick = () => {
|
84 |
+
unityInstance.SetFullscreen(1);
|
85 |
+
};
|
86 |
+
}
|
87 |
+
}).catch((message) => {
|
88 |
+
alert(message);
|
89 |
+
});
|
90 |
+
};
|
91 |
+
document.body.appendChild(script);
|
92 |
+
</script>
|
93 |
+
<script type="text/javascript">
|
94 |
+
function readFromClipboard() {
|
95 |
+
navigator.clipboard.readText().then(
|
96 |
+
function (text) {
|
97 |
+
if (typeof UnityInstance !== 'undefined') {
|
98 |
+
UnityInstance.SendMessage('ClipboardManager', 'OnTextPasted', text);
|
99 |
+
}
|
100 |
+
},
|
101 |
+
function (err) {
|
102 |
+
console.error('Error al leer del portapapeles: ', err);
|
103 |
+
}
|
104 |
+
);
|
105 |
+
}
|
106 |
+
</script>
|
107 |
</body>
|
108 |
|
109 |
</html>
|