Web GL Publish does not work for me
Hi all, I am trying to publish my Unity Web GL build. Uncompressed build. Unity Editor: Menu > Publish > WebGL Project Upload Complete; browser opens with Play button. Play: shows [90%] "The first play through is recorded to add a preview of the game." - and there it is stuck forever. Dev console in browser shows multiple errors: - otBannerSdk.js:7 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'style') website-search-1.4.js:1 Error: no render target found, search-box requires attachSearchBox to be set Project_WebglDetailV2Controller.ee70871274b0619cc6f1.bundle.js:1 Uncaught DOMException: Blocked a frame with origin "https://play.unity.com" from accessing a cross-origin frame. at https://play-static.unity.com/public/assets/Project/Project_WebglDetailV2Controller.ee70871274b0619cc6f1.bundle.js:1:376891 mow-unity-4.loader.js:1 GET https://play-static.unity.com/20211204/webgl/c06e1eef-8716-42d3-aa45-0273b64bcff6/Build/ net::ERR_ABORTED 404 (Not Found) mow-unity-4.loader.js:1 Unable to load file https://play-static.unity.com/20211204/webgl/c06e1eef-8716-42d3-aa45-0273b64bcff6/Build/! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug) GET https://play-static.unity.com/20211204/webgl/c06e1eef-8716-42d3-aa45-0273b64bcff6/Build/ 404 (Not Found) [UnityCache] 'https://play-static.unity.com/20211204/webgl/c06e1eef-8716-42d3-aa45-0273b64bcff6/Build/' request failed with status: 404 Not Found
Please help. Thank you
Answer by nicca_NJ · Dec 05, 2021 at 09:22 AM
I also experiencing this now. I don't know how to solve this issue if you have a solution pls help us
This editor made me swear badly not once!
Crammed almost all I tried to, but one line still went south.
It should be: Web.config:
<remove fileExtension=".unityweb" />
<mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />
Answer by gfilkov · Dec 07, 2021 at 12:58 AM
Hi @nicca_NJ I assume there are different situations for different people. Not sure if my recipe works for you, but you are free to try it ;)
My issue was: my Unity project had scene with InputField on the canvas. Everything worked when deployed in IIS on my localhost. Publishing WebGL would either fail completely or disable InputField, with multiple errors logged in the browser.
All I could achieve was publishing WebGL build on my server in Azure. If it helps, here is what I did to make it work:
C# (my code: KeyboardClass.cs)
void Start() { #if !UNITY_EDITOR && UNITY_WEBGL // disable WebGLInput.captureAllKeyboardInput so elements in web page can handle keabord inputs WebGLInput.captureAllKeyboardInput = false; #endif }
Build config:
Project Settings > Player > Settings for WebGL > Publishing Settings
Explicitly Thrown Exceptions Only
Throw Gzip Data Caching [v]
Decompression Fallback [v]
=Build/Index.html add:
var recaptureInputAndFocus = function() {
//var canvas = document.getElementById("#canvas");
if(canvas) {
canvas.setAttribute("tabindex", "1");
canvas.focus();
} else
setTimeout(recaptureInputAndFocus, 100);
}
Deployed to Azure (added to my existing webapp)
Web.config add:
<remove fileExtension=".unityweb" />
As the result: my project works fine in browsers on PC. But it fails to load on mobile devices :( Previous version, 90 MB, worked fine both on PC and mobile. New version, 170 MB - fails to load on mobiles. Works on PC only.