Search Unity

Unable to run local Unity WebGL (file:// url) All browsers, except Edge!

Discussion in 'Editor & General Support' started by LootHunter, Jul 12, 2019.

  1. LootHunter

    LootHunter

    Joined:
    May 27, 2017
    Posts:
    66
    Hello. I've got a problem with launching my games made with Unity in a browser.

    Or more specifically, games embedded in HTML pages on my computer don't launch at all. And all I get is this message:

    It seems your browser does not support running Unity WebGL content from file:// urls. Please upload it to an http server, or try a different browser.
    This happens in Firefox, Google Chrome, Opera, Internet Explorer. Only in Microsoft Edge, my games are still working. I think three or four days back everything was fine - I've launched some of my games. But now, here is this.

    So. What the hell is happening? How do I fix the problem?
     
    iosphere, ZenUnity and EvOne like this.
  2. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    173
    The same story. After updating FireFox to ver 68

    for FireFox this advice helped me:
    change "privacy.file_unique_origin" to "false" in about:config

    (from here: http://forums.mobirise.com/discussion/21485/issues-with-latest-firefox-68-0-previewing-sites-locally)
    2019-07-21_16-33-08.png
     
  3. JediGiovanni

    JediGiovanni

    Joined:
    Aug 4, 2019
    Posts:
    1
    I have the same story. All browsers were working before with WebGL. I'm unsure why it's saying it's not supported now. All my browsers are up to date too.
    I might have to download Firefox then.
     
  4. iosphere

    iosphere

    Joined:
    Dec 28, 2019
    Posts:
    13
    Same problem here. And I just completely re-insalled firefox. No luck.
     
  5. GooDtoLivE

    GooDtoLivE

    Joined:
    Oct 2, 2016
    Posts:
    1
    The same problem with my WebGL demo, Does anyone succeed?
     
  6. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    If you do build and run unity starts a small server in the background that is hosting the webpage and the webgl export so you can access it via your localhost adress.
    That you can not just open the file in your webbroser is because most of the major browser do value the users security more than the super slim chance that you might be opening a local html file.
    If you like to host the file on your pc more permanently you can install a lightweight webserver to host your webgl build.
    (my personal preference is XAMPP )
     
    jesper42 likes this.
  7. Bodin

    Bodin

    Joined:
    Apr 19, 2017
    Posts:
    37
    EvOne likes this.
  8. Andre_Santos

    Andre_Santos

    Joined:
    Dec 12, 2012
    Posts:
    3
    AlexSD3, regalk and Edudjr like this.
  9. alexandrinio10

    alexandrinio10

    Joined:
    Jul 15, 2020
    Posts:
    1
    One way to solve this is after building your project:
    • Sign-in to your Account inside Unity Editor
    • Select Window > Share WebGL Game , from the top-menu
    • Share your project
     
  10. vinnyTeles

    vinnyTeles

    Joined:
    Nov 10, 2019
    Posts:
    2
    A simple way to test your webGL game locally is using a local server like XAMPP.

    Save a copy of your game build on xampp\htdocs folder. Starts Apache module in XAMPP control panel, and acess your game by an URL like this:

    http://localhost/<your-game-folder-name>/
     
  11. narengoku

    narengoku

    Joined:
    Sep 17, 2017
    Posts:
    1
    EvOne likes this.
  12. Chaaarles666

    Chaaarles666

    Joined:
    Jul 29, 2020
    Posts:
    1
    Hey dude, XAMPP may be a good choice but why not try to start an HTTP server in a simple way?

    Just open your terminal and go into your directory (where the HTML file lies), and start the server using one of the commands below.

    > python -m CGIHTTPServer 8360
    > python -m http.server --cgi 8360
    > python3 -m http.server --cgi 8360

    This will open the port for you.

    Then direct your browser to http://localhost:8360/YOURFILENAME.html
    The default one would usually be index.html ;)
     
  13. Edudjr

    Edudjr

    Joined:
    Nov 6, 2013
    Posts:
    2
    That's probably the easiest way to do it.
    Once you have your server running on local host, we can use https://ngrok.com/ with the same server port in order to access the build over the internet :)
     
  14. LootHunter

    LootHunter

    Joined:
    May 27, 2017
    Posts:
    66
    thomas4d and EvOne like this.
  15. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    173
    :(
     
  16. Kasaie

    Kasaie

    Joined:
    Feb 2, 2015
    Posts:
    598
    These instructions were found in Dr. Tim Chamillard's game development course:

    Firefox (recommended browser for running WebGL)

    1. Type about:config in the navigation bar
    2. Search for the security.fileuri.strict_origin_policy parameter
    3. Click that parameter to change it to false
    Chrome

    1. Add a shortcut to Chrome on your desktop if you don't have one
    2. Right click the shortcut and select Properties
    3. Select the Target text box, go to the end, add a space and add --allow-file-access-from-files
    4. Double-click the index html file for the WebGL build and copy the URL in the navigation bar when the browser opens
    5. Close the browser
    6. Start the browser using the shortcut, paste in the URL you copied in Step 4 and press enter
    Microsoft Edge

    No need to do anything, WebGL builds work fine.

    Safari

    1. Enable the develop menu using the preferences panel, under Advanced → “Show develop menu in menu bar”
    2. From the safari “Develop” menu, select “Disable local file restrictions”
     
    LootHunter likes this.
  17. YasanthaPrabath

    YasanthaPrabath

    Joined:
    Jul 2, 2010
    Posts:
    13
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Just Build and Run from Unity, it will launch a small web server locally.
     
  19. thomas4d

    thomas4d

    Joined:
    Sep 5, 2013
    Posts:
    56
    OLD info does not work in 7/7/2022 edge is not working firefox also not working with local WebGL
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you mean via file:// url? Or from Unity with Build and Run
     
  21. ankitrajdwivedi01

    ankitrajdwivedi01

    Joined:
    Aug 29, 2023
    Posts:
    5
    Follow these simple steps to run unity webgl game locally.
    1. Install python server in your local machine.
    2. Build your project from unity.
    3. Navigate to your build folder
    4. open cmd in current directory.
    5. Run command for windows user : > python -m http.server and > python3 -m http.server on Mac.
    6. It shows the port number.
    7. Open any browser in your system and type localhost: portNumber in my case it is localhost:8000 hit enter your game will run locally.
     
  22. sklbz_

    sklbz_

    Joined:
    May 25, 2023
    Posts:
    1
    if npm is installed then opne the terminal in the folder containing the index.html file and try
    Code (csharp):
    1. npx serve