bebechien commited on
Commit
6db9cc6
·
1 Parent(s): 2109992

Add Unity WebGL build files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Build/* filter=lfs diff=lfs merge=lfs -text
Build/html5.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8515745030730c8b194e548db86fa5aeda84699586b0207f85ab82d0957cab9e
3
+ size 12562141
Build/html5.framework.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c3882e6c0d50e06572c6ef5b5e6f2fb88d11a23c0e5ee09213e11ae4a60fc03
3
+ size 339659
Build/html5.loader.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9df02597f4b6d154b16140c995a3836d4c8584233bd11edc97d768c33d401a5
3
+ size 19031
Build/html5.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8af394699a1414d17c8840ff6701ff51220ff7fdacc57a97a644875539663c7c
3
+ size 13170616
TemplateData/favicon.ico ADDED
TemplateData/fullscreen-button.png ADDED
TemplateData/progress-bar-empty-dark.png ADDED
TemplateData/progress-bar-empty-light.png ADDED
TemplateData/progress-bar-full-dark.png ADDED
TemplateData/progress-bar-full-light.png ADDED
TemplateData/style.css ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body { padding: 0; margin: 0 }
2
+ #unity-container { position: absolute }
3
+ #unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
4
+ #unity-container.unity-mobile { width: 100%; height: 100% }
5
+ #unity-canvas { background: #231F20 }
6
+ .unity-mobile #unity-canvas { width: 100%; height: 100% }
7
+ #unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
8
+ #unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
9
+ #unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center }
10
+ #unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
11
+ #unity-footer { position: relative }
12
+ .unity-mobile #unity-footer { display: none }
13
+ #unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
14
+ #unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
15
+ #unity-fullscreen-button { float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
16
+ #unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }
TemplateData/unity-logo-dark.png ADDED
TemplateData/unity-logo-light.png ADDED
TemplateData/webgl-logo.png ADDED
index.html CHANGED
@@ -1,19 +1,119 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en-us">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
+ <title>Unity WebGL Player | My project</title>
7
+ <link rel="shortcut icon" href="TemplateData/favicon.ico">
8
+ <link rel="stylesheet" href="TemplateData/style.css">
9
+ </head>
10
+ <body>
11
+ <div id="unity-container" class="unity-desktop">
12
+ <canvas id="unity-canvas" width=960 height=600></canvas>
13
+ <div id="unity-loading-bar">
14
+ <div id="unity-logo"></div>
15
+ <div id="unity-progress-bar-empty">
16
+ <div id="unity-progress-bar-full"></div>
17
+ </div>
18
+ </div>
19
+ <div id="unity-warning"> </div>
20
+ <div id="unity-footer">
21
+ <div id="unity-webgl-logo"></div>
22
+ <div id="unity-fullscreen-button"></div>
23
+ <div id="unity-build-title">My project</div>
24
+ </div>
25
+ </div>
26
+ <script>
27
+ var container = document.querySelector("#unity-container");
28
+ var canvas = document.querySelector("#unity-canvas");
29
+ var loadingBar = document.querySelector("#unity-loading-bar");
30
+ var progressBarFull = document.querySelector("#unity-progress-bar-full");
31
+ var fullscreenButton = document.querySelector("#unity-fullscreen-button");
32
+ var warningBanner = document.querySelector("#unity-warning");
33
+
34
+ // Shows a temporary message banner/ribbon for a few seconds, or
35
+ // a permanent error message on top of the canvas if type=='error'.
36
+ // If type=='warning', a yellow highlight color is used.
37
+ // Modify or remove this function to customize the visually presented
38
+ // way that non-critical warnings and error messages are presented to the
39
+ // user.
40
+ function unityShowBanner(msg, type) {
41
+ function updateBannerVisibility() {
42
+ warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
43
+ }
44
+ var div = document.createElement('div');
45
+ div.innerHTML = msg;
46
+ warningBanner.appendChild(div);
47
+ if (type == 'error') div.style = 'background: red; padding: 10px;';
48
+ else {
49
+ if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
50
+ setTimeout(function() {
51
+ warningBanner.removeChild(div);
52
+ updateBannerVisibility();
53
+ }, 5000);
54
+ }
55
+ updateBannerVisibility();
56
+ }
57
+
58
+ var buildUrl = "Build";
59
+ var loaderUrl = buildUrl + "/html5.loader.js";
60
+ var config = {
61
+ dataUrl: buildUrl + "/html5.data",
62
+ frameworkUrl: buildUrl + "/html5.framework.js",
63
+ codeUrl: buildUrl + "/html5.wasm",
64
+ streamingAssetsUrl: "StreamingAssets",
65
+ companyName: "DefaultCompany",
66
+ productName: "My project",
67
+ productVersion: "1.0",
68
+ showBanner: unityShowBanner,
69
+ };
70
+
71
+ // By default Unity keeps WebGL canvas render target size matched with
72
+ // the DOM size of the canvas element (scaled by window.devicePixelRatio)
73
+ // Set this to false if you want to decouple this synchronization from
74
+ // happening inside the engine, and you would instead like to size up
75
+ // the canvas DOM size and WebGL render target sizes yourself.
76
+ // config.matchWebGLToCanvasSize = false;
77
+
78
+ if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
79
+ // Mobile device style: fill the whole browser client area with the game canvas:
80
+
81
+ var meta = document.createElement('meta');
82
+ meta.name = 'viewport';
83
+ meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
84
+ document.getElementsByTagName('head')[0].appendChild(meta);
85
+ container.className = "unity-mobile";
86
+ canvas.className = "unity-mobile";
87
+
88
+ // To lower canvas resolution on mobile devices to gain some
89
+ // performance, uncomment the following line:
90
+ // config.devicePixelRatio = 1;
91
+
92
+ unityShowBanner('WebGL builds are not supported on mobile devices.');
93
+ } else {
94
+ // Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
95
+
96
+ canvas.style.width = "960px";
97
+ canvas.style.height = "600px";
98
+ }
99
+
100
+ loadingBar.style.display = "block";
101
+
102
+ var script = document.createElement("script");
103
+ script.src = loaderUrl;
104
+ script.onload = () => {
105
+ createUnityInstance(canvas, config, (progress) => {
106
+ progressBarFull.style.width = 100 * progress + "%";
107
+ }).then((unityInstance) => {
108
+ loadingBar.style.display = "none";
109
+ fullscreenButton.onclick = () => {
110
+ unityInstance.SetFullscreen(1);
111
+ };
112
+ }).catch((message) => {
113
+ alert(message);
114
+ });
115
+ };
116
+ document.body.appendChild(script);
117
+ </script>
118
+ </body>
119
  </html>