Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Build/unity-webgl-build.data.gz
Binary file not shown.
Binary file removed Build/unity-webgl-build.data.unityweb
Binary file not shown.
Binary file added Build/unity-webgl-build.framework.js.gz
Binary file not shown.
Binary file removed Build/unity-webgl-build.framework.js.unityweb
Binary file not shown.
2 changes: 1 addition & 1 deletion Build/unity-webgl-build.loader.js

Large diffs are not rendered by default.

Binary file added Build/unity-webgl-build.wasm.gz
Binary file not shown.
Binary file removed Build/unity-webgl-build.wasm.unityweb
Binary file not shown.
2 changes: 1 addition & 1 deletion TemplateData/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body { padding: 0; margin: 0 }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
#unity-footer { position: relative }
.unity-mobile #unity-footer { display: none }
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
#unity-logo-title-footer { float:left; width: 102px; height: 38px; background: url('unity-logo-title-footer.png') no-repeat center }
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
#unity-fullscreen-button { cursor:pointer; float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }
Binary file added TemplateData/unity-logo-title-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed TemplateData/webgl-logo.png
Binary file not shown.
45 changes: 28 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | unity-modal-example</title>
<title>Unity Web Player | unity-modal-example</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
</head>
Expand All @@ -18,19 +18,13 @@
</div>
<div id="unity-warning"> </div>
<div id="unity-footer">
<div id="unity-webgl-logo"></div>
<div id="unity-logo-title-footer"></div>
<div id="unity-fullscreen-button"></div>
<div id="unity-build-title">unity-modal-example</div>
</div>
</div>
<script>

var container = document.querySelector("#unity-container");
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBarFull = document.querySelector("#unity-progress-bar-full");
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
var warningBanner = document.querySelector("#unity-warning");

// Shows a temporary message banner/ribbon for a few seconds, or
// a permanent error message on top of the canvas if type=='error'.
Expand All @@ -39,6 +33,7 @@
// way that non-critical warnings and error messages are presented to the
// user.
function unityShowBanner(msg, type) {
var warningBanner = document.querySelector("#unity-warning");
function updateBannerVisibility() {
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
}
Expand All @@ -59,14 +54,21 @@
var buildUrl = "Build";
var loaderUrl = buildUrl + "/unity-webgl-build.loader.js";
var config = {
dataUrl: buildUrl + "/unity-webgl-build.data.unityweb",
frameworkUrl: buildUrl + "/unity-webgl-build.framework.js.unityweb",
codeUrl: buildUrl + "/unity-webgl-build.wasm.unityweb",
arguments: [],
dataUrl: buildUrl + "/unity-webgl-build.data.gz",
frameworkUrl: buildUrl + "/unity-webgl-build.framework.js.gz",
codeUrl: buildUrl + "/unity-webgl-build.wasm.gz",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "unity-modal-example",
productVersion: "0.1",
showBanner: unityShowBanner,
// errorHandler: function(err, url, line) {
// alert("error " + err + " occurred at line " + line);
// // Return 'true' if you handled this error and don't want Unity
// // to process it further, 'false' otherwise.
// return true;
// },
};

// By default, Unity keeps WebGL canvas render target size matched with
Expand All @@ -76,14 +78,23 @@
// the canvas DOM size and WebGL render target sizes yourself.
// config.matchWebGLToCanvasSize = false;

// If you would like all file writes inside Unity Application.persistentDataPath
// directory to automatically persist so that the contents are remembered when
// the user revisits the site the next time, uncomment the following line:
// config.autoSyncPersistentDataPath = true;
// This autosyncing is currently not the default behavior to avoid regressing
// existing user projects that might rely on the earlier manual
// JS_FileSystem_Sync() behavior, but in future Unity version, this will be
// expected to change.

if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
// Mobile device style: fill the whole browser client area with the game canvas:

var meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
document.getElementsByTagName('head')[0].appendChild(meta);
container.className = "unity-mobile";
document.querySelector("#unity-container").className = "unity-mobile";
canvas.className = "unity-mobile";

// To lower canvas resolution on mobile devices to gain some
Expand All @@ -93,23 +104,23 @@

} else {
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:

canvas.style.width = "960px";
canvas.style.height = "600px";
}

loadingBar.style.display = "block";
document.querySelector("#unity-loading-bar").style.display = "block";

var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
document.querySelector("#unity-progress-bar-full").style.width = 100 * progress + "%";
}).then((unityInstance) => {
loadingBar.style.display = "none";
fullscreenButton.onclick = () => {
document.querySelector("#unity-loading-bar").style.display = "none";
document.querySelector("#unity-fullscreen-button").onclick = () => {
unityInstance.SetFullscreen(1);
};

}).catch((message) => {
alert(message);
});
Expand Down
72 changes: 42 additions & 30 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
{
"headers": [
{
"source": "Build/unity-webgl-build.framework.js.unityweb",
"headers": [
{
"key": "Content-Encoding",
"value": "gzip"
}
]
},
{
"source": "Build/unity-webgl-build.data.unityweb",
"headers": [
{
"key": "Content-Encoding",
"value": "gzip"
}
]
},
{
"source": "Build/unity-webgl-build.wasm.unityweb",
"headers": [
{
"key": "Content-Encoding",
"value": "gzip"
}
]
}
]
}
"headers": [
{
"source": "Build/unity-webgl-build.framework.js.gz",
"headers": [
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Content-Type",
"value": "application/javascript"
}
]
},
{
"source": "Build/unity-webgl-build.data.gz",
"headers": [
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Content-Type",
"value": "application/octet-stream"
}
]
},
{
"source": "Build/unity-webgl-build.wasm.gz",
"headers": [
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Content-Type",
"value": "application/wasm"
}
]
}
]
}