Skip to content

Commit 526ac79

Browse files
committed
Added Unity Build
1 parent 05d900f commit 526ac79

17 files changed

+139
-0
lines changed
Binary file not shown.
Binary file not shown.

react-project/public/UnityBuild/Build/Clicker.loader.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Loading
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 { position: fixed; 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 { cursor:pointer; 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 }
Loading
Loading
Loading
Loading
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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 | Clicker</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 tabindex="-1"></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">Clicker</div>
24+
</div>
25+
</div>
26+
<script>
27+
28+
var container = document.querySelector("#unity-container");
29+
var canvas = document.querySelector("#unity-canvas");
30+
var loadingBar = document.querySelector("#unity-loading-bar");
31+
var progressBarFull = document.querySelector("#unity-progress-bar-full");
32+
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
33+
var warningBanner = document.querySelector("#unity-warning");
34+
35+
// Shows a temporary message banner/ribbon for a few seconds, or
36+
// a permanent error message on top of the canvas if type=='error'.
37+
// If type=='warning', a yellow highlight color is used.
38+
// Modify or remove this function to customize the visually presented
39+
// way that non-critical warnings and error messages are presented to the
40+
// user.
41+
function unityShowBanner(msg, type) {
42+
function updateBannerVisibility() {
43+
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
44+
}
45+
var div = document.createElement('div');
46+
div.innerHTML = msg;
47+
warningBanner.appendChild(div);
48+
if (type == 'error') div.style = 'background: red; padding: 10px;';
49+
else {
50+
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
51+
setTimeout(function() {
52+
warningBanner.removeChild(div);
53+
updateBannerVisibility();
54+
}, 5000);
55+
}
56+
updateBannerVisibility();
57+
}
58+
59+
var buildUrl = "Build";
60+
var loaderUrl = buildUrl + "/Clicker.loader.js";
61+
var config = {
62+
dataUrl: buildUrl + "/Clicker.data.unityweb",
63+
frameworkUrl: buildUrl + "/Clicker.framework.js.unityweb",
64+
codeUrl: buildUrl + "/Clicker.wasm.unityweb",
65+
streamingAssetsUrl: "StreamingAssets",
66+
companyName: "AbyssMoth",
67+
productName: "Clicker",
68+
productVersion: "1.0.0.0",
69+
showBanner: unityShowBanner,
70+
};
71+
72+
// By default, Unity keeps WebGL canvas render target size matched with
73+
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
74+
// Set this to false if you want to decouple this synchronization from
75+
// happening inside the engine, and you would instead like to size up
76+
// the canvas DOM size and WebGL render target sizes yourself.
77+
// config.matchWebGLToCanvasSize = false;
78+
79+
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
80+
// Mobile device style: fill the whole browser client area with the game canvas:
81+
82+
var meta = document.createElement('meta');
83+
meta.name = 'viewport';
84+
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
85+
document.getElementsByTagName('head')[0].appendChild(meta);
86+
container.className = "unity-mobile";
87+
canvas.className = "unity-mobile";
88+
89+
// To lower canvas resolution on mobile devices to gain some
90+
// performance, uncomment the following line:
91+
// config.devicePixelRatio = 1;
92+
93+
94+
} else {
95+
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
96+
97+
canvas.style.width = "960px";
98+
canvas.style.height = "600px";
99+
}
100+
101+
loadingBar.style.display = "block";
102+
103+
var script = document.createElement("script");
104+
script.src = loaderUrl;
105+
script.onload = () => {
106+
createUnityInstance(canvas, config, (progress) => {
107+
progressBarFull.style.width = 100 * progress + "%";
108+
}).then((unityInstance) => {
109+
loadingBar.style.display = "none";
110+
fullscreenButton.onclick = () => {
111+
unityInstance.SetFullscreen(1);
112+
};
113+
}).catch((message) => {
114+
alert(message);
115+
});
116+
};
117+
118+
document.body.appendChild(script);
119+
120+
</script>
121+
</body>
122+
</html>

0 commit comments

Comments
 (0)