1

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

1 Answer 1

3

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).

Sign up to request clarification or add additional context in comments.

6 Comments

cant run on local machine if not build & run on unity if I just build it index.html is created on a folder I choose and when I want launch it on browser I got that Uncaught ReferenceError
Yes, don't open it straight from Explorer. You need a web server.
dont know anthing about webGL but I can launch normal hmtl and .js files locally with no error is it bcoz of webGL?
It's most likely because of Unity's engine for webGL. Because 'normal' security doesn't let you load js from file, Unity probably didn't include functions to load js from file in their code, only from HTTP.
thanks thats a relief :D hope it doesnt have any problems when running on server
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.