Skip to content

Commit

Permalink
feat: Build EcoGuardians 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StiivenOrtiz committed Nov 10, 2024
1 parent 5a55b41 commit 52efe72
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 49 deletions.
4 changes: 2 additions & 2 deletions Build/EcoGuardians-2.0.data
Git LFS file not shown
91 changes: 44 additions & 47 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | EcoGuardians 2.0</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico" />
<link rel="stylesheet" href="TemplateData/style.css" />
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
</head>
<body>
<div id="unity-container" class="unity-desktop">
<canvas id="unity-canvas" width="960" height="540" tabindex="-1"></canvas>
<canvas id="unity-canvas" width=960 height=540 tabindex="-1"></canvas>
<div id="unity-loading-bar">
<div id="unity-logo"></div>
<div id="unity-progress-bar-empty">
<div id="unity-progress-bar-full"></div>
</div>
</div>
<div id="unity-warning"></div>
<div id="unity-warning"> </div>
<div id="unity-footer">
<div id="unity-webgl-logo"></div>
<div id="unity-fullscreen-button"></div>
<div id="unity-build-title">EcoGuardians 2.0</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');

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,36 +40,32 @@
// user.
function unityShowBanner(msg, type) {
function updateBannerVisibility() {
warningBanner.style.display = warningBanner.children.length
? 'block'
: 'none';
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
}
var div = document.createElement('div');
div.innerHTML = msg;
warningBanner.appendChild(div);
if (type == 'error') div.style = 'background: red; padding: 10px;';
else {
if (type == 'warning')
div.style = 'background: yellow; padding: 10px;';
setTimeout(function () {
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
setTimeout(function() {
warningBanner.removeChild(div);
updateBannerVisibility();
}, 5000);
}
updateBannerVisibility();
}

var buildUrl = 'Build';
var loaderUrl = buildUrl + '/EcoGuardians-2.0.loader.js';
var buildUrl = "Build";
var loaderUrl = buildUrl + "/EcoGuardians-2.0.loader.js";
var config = {
dataUrl:
'https://media.githubusercontent.com/media/EcoGuardians-2-0/EcoGuardians-2.0/main/Build/EcoGuardians-2.0.data',
frameworkUrl: buildUrl + '/EcoGuardians-2.0.framework.js',
codeUrl: buildUrl + '/EcoGuardians-2.0.wasm',
streamingAssetsUrl: 'StreamingAssets',
companyName: 'EcoGuardians 2.0',
productName: 'EcoGuardians 2.0',
productVersion: '2.0',
dataUrl: buildUrl + "/EcoGuardians-2.0.data",
frameworkUrl: buildUrl + "/EcoGuardians-2.0.framework.js",
codeUrl: buildUrl + "/EcoGuardians-2.0.wasm",
streamingAssetsUrl: "StreamingAssets",
companyName: "EcoGuardians 2.0",
productName: "EcoGuardians 2.0",
productVersion: "2.0",
showBanner: unityShowBanner,
};

Expand All @@ -84,42 +81,42 @@

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';
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';
canvas.className = 'unity-mobile';
container.className = "unity-mobile";
canvas.className = "unity-mobile";

// To lower canvas resolution on mobile devices to gain some
// performance, uncomment the following line:
// config.devicePixelRatio = 1;


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

canvas.style.width = '960px';
canvas.style.height = '540px';
canvas.style.width = "960px";
canvas.style.height = "540px";
}

loadingBar.style.display = 'block';
loadingBar.style.display = "block";

var script = document.createElement('script');
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + '%';
})
.then((unityInstance) => {
loadingBar.style.display = 'none';
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
progressBarFull.style.width = 100 * progress + "%";
}).then((unityInstance) => {
loadingBar.style.display = "none";
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
};
}).catch((message) => {
alert(message);
});
};
})
.catch((message) => {
alert(message);
});
};

document.body.appendChild(script);

</script>
</body>
</html>

0 comments on commit 52efe72

Please sign in to comment.