Adding Unity WebGL build to a post

To start:

  • What’s your URL? https://mattmadethis.blog/games/
  • What version of Ghost are you using? Latest (cli 1.9.8 and ghost 2.6.2)
  • What configuration? Setup using Digital Ocean Ghost 1-click (Ubuntu 16.04)
  • What browser? Google Chrome
  • What errors or information do you see in the console? Failed to load resource: the server responded with a status of 404 ()
  • What steps could someone else take to reproduce the issue you’re having? Visit the URL linked above and inspect the page to view the console

Hi!

I am working on adding a build of a Unity game I made to a static blog post (potentially non-static ones in the future) and I am having some troubles getting it to serve up the files properly. There are some issues in Unity with this type of build so I was anticipating having some issues based on this documentation: Unity - Manual: Deploy WebGL application which covers the case of an IIS or Apache server but unfortunately doesn’t say anything about a node.js server. It looks like I need to change the mime types to allow the .unityweb extension, which I have done in the nginx server

  • open ~/etc/nginx/mime.types
  • add the line for the proper mime type, save and close
  • restart nginx

The other thing of note in that documentation is around removing the file extension for .unityweb, and I am not sure if that is something I need to do in this case.

Note that the <remove fileExtension=".unityweb" /> lines are required to handle a situation when content type is already overridden at a higher level in the server directory’s hierarchy, which could otherwise cause a server exception.

I am wondering if there are more changes I need to make to the express server to facilitate this as well. On a previous project with a similar server architecture (nginx, express, node) I got a unity build working on a simple single page application by loading the files statically in express like:

siteApp.use(express.static(path.join(__dirname, ‘public/unity’)));

I think part of my problem is figuring out where to store my Unity files. Should I store them in the express public directory ({ghost}/current/core/server/public)? Or since I am accessing them from inside my theme should I include them in the theme assets?

Sorry for the multi-part question, this has been plaguing me for days.
Happy to provide more info as needed.

Thanks!
Matt

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.