Be a Supporter!

Browse Sections

Introductory Information

Basic troubleshooting

One of the main issues with WebGL games seems to be caused by the site loading the game in an iframe. If you're having problems and this page doesn't help you, first load the game with your browser's developer console open and check if there are any errors. Then, try searching for keywords related to the issue you're having + iframe (e.g. "unity3d webgl keyboard focus iframe") or search for any non-obvious errors you see in the console.

We will continue to add issues and any workarounds or fixes we find here. If you've done some search and still haven't resolved the issue you're having, feel free to post a question in the Unity3D WebGL Support thread.

Please be sure to do the above basic troubleshooting first!

How to publish your game on NG

With Google's recent deprecation of NPAPI plugins, the WebGL export option in Unity 5 has become the only option for game developers to publish web based Unity games to Chrome users.

Unfortunately, this transition to WebGL has not been the easiest for many developers, and publishers like Newgrounds have had to make various changes to their server configurations to even support the way Unity has gone about implementing things.

Here is some introductory information on how to publish your WebGL unity games here on Newgrounds.

When you are ready, build your game. Make sure you are not doing a development build.

Once your game is built, you will have the following items in whatever folder you built to:
  • Compressed <dir>
  • Release <dir>
  • TemplateData <dir>
  • .htaccess
  • index.html


You will need to select the following items and add them to a zip file:

Release, TemplateData and index.html

The Release folder contains all your core game files. TemplateData contains your basic loader and css assets, and index.html is the file that loads all these others into the browser.

Once your zip file is ready, simply go to your game project and upload it.

You may be asking, why don't we use the .htaccess file and the Compressed folder. The short answer is security.

An .htaccess file essentially lets a directory override certain settings from the web server. In this case, it is used to tell your game to use the compressed version of your game instead of the release version. Unfortunately, we can not allow the general public to use .htaccess files because they could be used maliciously.

The good news is our servers will automatically compress your files when users load them. So if your release folder is actually around 100mb, the end user will only download 20mb or so.

Because you are putting your game in a zip file, your uploads will also be compressed, so you won't be waiting for 100+mb of data (unless your game is THAT huge compressed).

Including the .htaccess file and Compressed folder in your zip won't really hurt anything, but it will add the size of your compressed files to your upload and essentially double your wait time.

Common Problems

Keyboard events are not working

Try this workaround or this workaround if you're using jQuery.

Arrow keys cause the whole page to scroll

Try adding a simple javascript snippet to your index.html file:

<script type="text/javascript">

    

    // prevents key presses from bubbling out to the browser window

    var ignore_keycodes = [37,38,39,40];

    

    window.addEventListener('keydown', function(e) {

        if (ignore_keycodes.indexOf(e.keyCode) > -1) {

            e.preventDefault();

        }

    });

</script>


Add this code anywhere inside of the <body> tag and you should be good to go.

You can add other key codes to the ignore_keycodes array as needed.

If you need to ignore the mouse wheel:

<script type="text/javascript">

    // prevents scroll wheel from bubbling up to browser window

    window.addEventListener('wheel', function(e) {

        e.preventDefault();

    });

</script>


You can use this same trick for pretty much any Javascript event.