Search code examples
unity-game-engineunity-webgl

how to launch unity WebGL on browser


I build on unity successfully

if I run and build on unity it works

but when I run index.html on browser from build folder;

first it has been blocked by CORS policy I created a chrome shortcut disables security

then I got

Uncaught ReferenceError: unityFramework is not defined at HTMLScriptElement.n.onload

I looked into it and some said that to disable compression but I got more errors:

enter image description here

dont know much about webGL and not sure if its a problem on unity or browser

pls help

ps:my unity version is 2020.1.0f1


Solution

  • Browsers won't load javascripts (.js files) from a file system directly. You have to host them on a server. Running the server on your local machine is fine (it's what Unity does).