0
\$\begingroup\$

I've made a simple game but when I tried to load this on chrome its not loading.

I am building for WebGL (HTML 5). I am getting these errors when the page loads.

Unity version - 5.3.1f1 Chrome version - 47.0.2526.106 m

Its working fine on firefox .

XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.jsgz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.DecompressAndLoadFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.mem. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.memgz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.DecompressAndLoadFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.data. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.datagz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Why its not loading up on chrome ?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

I believe the issue is occuring because you are running it locally rather than on a webserver or an emulated webserver.

Basically: You need it to say http:// or https:// or whatever rather than file:// in the address bar

If you have a webserver, try uploading it there. If not, check out WAMP or XAMPP

I can recommend WAMP for people with little to no experience in "webserver emulation", but remember to either quit Skype or change the port which Skype uses as WAMP will use the same port which doesn't work.

\$\endgroup\$
5
  • \$\begingroup\$ ok let me check \$\endgroup\$ Commented Jan 4, 2016 at 12:52
  • \$\begingroup\$ I uploaded the .html file on kongregate and its not loading there too. \$\endgroup\$ Commented Jan 4, 2016 at 13:31
  • \$\begingroup\$ If you only uploaded the HTML then it won't work at all. You need the other files too. I'm not sure how Kongregate handles WebGL games so you might wanna ask them on a support email or something. Last time I checked they didn't support WebGL but they did support HTML files with frames which basically just shows a different website. I'd still recommend getting it to work with WAMP. There should be a bunch of guides online which tell you how to set WAMP up. How much experience do you have in web development? \$\endgroup\$
    – HappyGuyDK
    Commented Jan 4, 2016 at 14:04
  • \$\begingroup\$ not much, know basic HTML and CSS \$\endgroup\$ Commented Jan 4, 2016 at 14:14
  • \$\begingroup\$ zipping and uploading .zip file is working on kongregate . Ultimately that's what I wanted . \$\endgroup\$ Commented Jan 4, 2016 at 14:55
0
\$\begingroup\$

try in Firefox.

Here is related info from Unity doc: "You can view your WebGL player directly in most browsers by simply opening the index.html file. For security reasons, Chrome places restrictions on scripts opened from local file: URLs, so this technique will not work. If you use Unity’s Build & Run command (menu: File > Build & Run) then the file will be temporarily hosted in a local web server and opened from a localhost URL (this avoids the security restrictions). You can also run Chrome with the --disable-web-security command line option to enable it to load content from file: urls."

https://docs.unity3d.com/Manual/webgl-building.html

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .