It is important to note that this template is meant for games uploaded to and hosted on Kongregate, and it may not function properly if you are hosting the game yourself. You can save this file as Assets/WebGLTemplates/Kongregate/index.html in your project, and it should show up in the Player Settings for WebGL, as shown below: It removes margin/padding, loads the Kongregate Javascript API by including in the head tag, features a progress bar, and has an indeterminate spinner: The following is a template based on a wonderful example from The Alex Ocias Blog. This is also an important step because it allows you to load the Kongregate Javascript API. Unity allows you to specify an HTML template for your WebGL build, which you can style to your liking. Note: If you are using Unity 5.6 or higher, an updated version of the following template can be found here. Luckily, since many developers face this problem, there is a great chance that someone has already figured out how to do this for your particular server framework.įor one of our games using Python with Google App Engine the fix turned out to be the addition of one line in a common request handler class: _header('Access-Control-Allow-Origin', '*') Using an HTML Template Depending on the complexity of your server code, this could be a one-line fix or a fairly complex modification. Enable CORS is a wonderful resource for determining how to do this for your particular server application. In order for HTTP requests to keep functioning properly in a WebGL build, Cross Origin Resource Sharing must be enabled on the server. If you are using any plugins for your game, make sure to update them to the latest versions to address any potential issues. In general, anywhere you have a #if UNITY_Web Player block you will want to replace it with a #if UNITY_Web Player || UNITY_WEBGL block. If you already have a functioning Web Player build the changes required for WebGL should be fairly minimal.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |