Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Question How to Load WebGL Games

Discussion in 'WebGL' started by JoDoyle12, Sep 3, 2022.

  1. JoDoyle12

    JoDoyle12

    Joined:
    Aug 27, 2020
    Posts:
    1
    I have been looking all over been to ocuntless threads from 2011 and 2018 and theyve all used outdated and obsolete ways, so i have unity build in wegbl of my game and im wondering how to i run it on a website so others can play, preferbly not using itch.io or simmer.io, im currently using wix or wordpress to try and host my website but im open to any service
     
    MiguelAppStudio likes this.
  2. diegoop

    diegoop

    Joined:
    May 7, 2014
    Posts:
    8
    Hi @JoDoyle12, not sure if I'm missing something, but if you just upload the content of your build folder to your server and open the index.html that Unity generates, you should be able to play the game from there.

    If you want to include your game in some other specific page, you can copy the content from the Index.html to the page you want to use or modify that html file as you need.

    If for example, you want to use a Wordpress site, I would probably create a php template, insert you html code there and create a page using that template.
     
  3. cuentaclientediana

    cuentaclientediana

    Joined:
    Sep 16, 2022
    Posts:
    4
    This is interesting, but I don't quite understand the documentation of your link.
    Still, what should we do with the Build and TemplateData folders and the index.html file?
    I have tried to upload it to the website and it always shows the same error:
    Failed to download file Build/ParaSubirWordPress.data.gz. Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.
    Can you give any more ideas ?
    Thank you
     
  4. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    233
    That error indicates you are trying to load files that are stored in your local file system. Browsers refuse to load files from the local file system via the file:// URL for security reasons. You need to set a URL that either points to the same domain where you host your Unity game at (via the same protocol http:// or https:// where you host the page), or to an external domain, but then you'll have to configure your web server to enable CORS access to the web server domain where the Unity game runs at.
     
  5. cuentaclientediana

    cuentaclientediana

    Joined:
    Sep 16, 2022
    Posts:
    4
    I have a question :
    - Would you tell me where I can find the correct documentation to configure a URL that points to the same domain where I will host my Game?
    - Where is the correct information to configure your web server to enable CORS access?
    I would be very grateful if you can provide me with a link to be able to carry out the steps that you tell me.
    I have searched in Google, but maybe I am not searching for the correct terms, but I do not find anything similar
    Thank you @unityruba