Skip to content

Commit

Permalink
Fixed previous bugs.
Browse files Browse the repository at this point in the history
Introduced more bugs to fix in future.
  • Loading branch information
saadjumani committed Apr 15, 2022
1 parent 84fd663 commit 70830f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Binary file modified Build/Demo.data
Binary file not shown.
Binary file modified Build/Demo.wasm
Binary file not shown.
9 changes: 9 additions & 0 deletions MyLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ function createUnityInstance(canvas, config, onProgress) {
} else if (message.indexOf("Invalid array buffer length") != -1 || message.indexOf("Invalid typed array length") != -1 || message.indexOf("out of memory") != -1 || message.indexOf("could not allocate memory") != -1) {
message = "The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings.";
}

alert(message);
errorHandler.didShowErrorMessage = true;
}
Expand Down Expand Up @@ -291,6 +292,14 @@ function createUnityInstance(canvas, config, onProgress) {
}
var totalProgress = started ? (started - unfinishedNonComputable - (total ? computable * (total - loaded) / total : 0)) / started : 0;
onProgress(0.9 * totalProgress);

var LBar = document.getElementById("LoadBar");
var CBar = document.getElementById("LoadContainer");
LBar.style.width = totalProgress*200+"px";
if(totalProgress == 1){
CBar.style.display="none";
}

}

Module.XMLHttpRequest = function () {
Expand Down
16 changes: 7 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,21 @@
<div class="webgl-wrapper">
<div class="aspect"></div>
<div class="webgl-content">
<div id="unityContainer">
<canvas id="unity-canvas" style="background: #231F20"></canvas>
<div id="unityContainer">

<div id="LoadContainer" style="display: block; position: absolute; top: 50%; left: 50%; margin-left: -100px; margin-top: -7px; height: 15px; width: 200px; border-style: solid; border: color #999; border-width: 1px; z-index: 9;">
<div id="LoadBar" style="display: block; background-color: white; height: 15px; width: 0px; z-index: 10;"></div>
</div>
<canvas id="unity-canvas" style="background: #231F20;"></canvas>
</div>
</div>
</div>
</div>

<div class="info">
<p>unity webgl responsive</p>
<p>press F or <a href="#" onclick="myGameInstance.SetFullscreen(1)">click here</a> to toggle fullscreen</p>
</div>

<!-- feel free to remove all credits! -->
<div class="info">
<p>source code on <a href="https://github.com/sno/unity-webgl-responsive">github</a></p>
<p>template by dom / <a href="https://twitter.com/zerstoerer">@zerstoerer</a></p>
</div>

<script src="MyLoader.js"></script>
<script>
createUnityInstance(document.querySelector("#unity-canvas"), {
Expand Down

0 comments on commit 70830f8

Please sign in to comment.