Unity3D on the web

In order for the game-based simulation that I’m working on to work, I’m going to have to be able to export my game to WebGL from Unity3D so that users won’t have to fuss with installing extra plugins before they can experience it. To test this, I have exported my result from the Roll-a-Ball tutorial on the Unity3D site to WebGL to see how that goes. The code is surprisingly simple in the resulting HTML page that is automatically generated. Instead of just linking to the page, however, I wanted to embed it into this post so that I could be sure to get the game to show up where and how I want it to. Here is the result (use your arrow keys to control the ball to pick up the yellow boxes):



Embedding this in a WordPress site like mine has some issues, the biggest of which is that the HTML generated from Unity includes some Javascript references in the head and since the post editor doesn’t have access to the HEAD tag, I had to work around it. At first I tried an IFRAME but since the game was in a different page than the post, the user would have to click on the game to get the controls to work.

My end solution was to just move the script reference down into the post with the rest of the code. Not ideal, but it works.

Please like & share: