Hey.
I’ve finally had some success with Web GL. All my projects that never successfully built were started in Unity 4 and upgraded to 5. By starting a clean new U5 project and importing all the old assets as a Package (which involves redoing almost all of the Layers & Sorting Layers and Inputs) then Web GL builds finally ran for me, locally.
I previously hosted my game jam games built with the old Web Player on Squarespace.com. I’d upload the build to Dropbox, then edit the .html file as a .txt to change the local address of the unity file to the public Dropbox address. After that I’d embed the new html code in a Squarespace ‘Code’ input and it would work (not on Chrome, of course).
Web GL builds work similarly I’m presuming, though it’s a bit more complicated. I’ve opened the .index file with a text editor and changed where it’s looking for the:
dataUrl
codeUrl
memUrl
and UnityLoader.gz files. Again, to my new public Dropbox location.
At this stage there was a hiccup. The files were actually built as .datagz, .jsgz etc. When I looked for the files with ‘gz’ on the end, the game wouldn’t run, even locally. So in the index file I removed the gz and now the game would run on my machine within the Dropbox folder.
I copied the code now and went to Squarespace to embed it in a page but the game won’t run. The same page gives me the following error in Chrome:
If running in Firefox I get this one:
The bottom of this Unity page says to make sure that the “server” is CORS enabled. I presume that in my case this is Dropbox? Dropbox is CORS enabled as far as my research goes, though I’ve no idea what that really means.
I’ve tried editing the files to remove the .gz extension and tried different combos of code but nothing works.
Is this a Squarespace problem? I don’t think it is. I think it’s me incorrectly doing the edit. Does anyone know what to do to get this working? I must finally slay the WebGL demon!
Thanks in advance.
My index.html file looks like this:
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Teluma</title>
<link rel="stylesheet" href="TemplateData/style.css">
<link rel="shortcut icon" href="TemplateData/favicon.ico" />
<script src="TemplateData/UnityProgress.js"></script>
</head>
<body class="template">
<p class="header"><span>Unity WebGL Player | </span>Teluma</p>
<div class="template-wrap clear">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="600px" width="800px"></canvas>
<div class="logo"></div>
<div class="fullscreen"><img src="TemplateData/fullscreen.png" width="38" height="38" alt="Fullscreen" title="Fullscreen" onclick="SetFullscreen(1);" /></div>
<div class="title">Teluma</div>
</div>
<p class="footer">« created with <a href="http://unity3d.com/" title="Go to unity3d.com">Unity</a> »</p>
<script type='text/javascript'>
var Module = {
TOTAL_MEMORY: 268435456,
errorhandler: null, // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
compatibilitycheck: null,
dataUrl: "https://dl.dropboxusercontent.com/u/70298032/Games/Teluma%20v0.2.0/Release/Teluma%20v0.2.0.data",
codeUrl: "https://dl.dropboxusercontent.com/u/70298032/Games/Teluma%20v0.2.0/Release/Teluma%20v0.2.0.js",
memUrl: "https://dl.dropboxusercontent.com/u/70298032/Games/Teluma%20v0.2.0/Release/Teluma%20v0.2.0.mem",
};
</script>
<script src="https://dl.dropboxusercontent.com/u/70298032/Games/Teluma%20v0.2.0/Release/UnityLoader.js"></script>
</body>
</html>