Source code is available on my Github Repository.
I created a new WebGL Template that would position my game in a Canvas object that will expand over the whole screen to simulate a FullScreen window. Check my Full Screen WebGL Template for more information.
The build is then hosted hosted on Github Pages and is inspired by it's default static site system to add content in the form of Markdown files.
I used the library FancyTextRendering to parse my MD files and store them into text boxes that support Rich Text rendering to speed up the addition of new content in my pages.
In order to limit the initial loading time of the project, I moved some of the heaviest files into Unity's Streaming Assets folder, and fetch the file on runtime when needed through HTML requests.
In order to avoid rebuilding the project and deplyong each time a change is made, I set up a quick Github Action that would listen to the commits in the repository using Game CI.
Each time a new push is detected, the action would trigger to make a new WebGL build and deploy it on the gh-pages branch, that is set up as source for the deoplyed website.
Since the view is effectively just an Unity game window, all the resemblances to a regular website are just simulated in the engine and many of those expected behaviours are still not implemented yet. Some examples are:
- Text size adapting according to the view setting
- Not being able to select and copy text
- Not being able to zoom in and out by pinching and dragging on mobile
- The back button would make the user leave the game view
- Scrolling with middle mouse button doesn't work
-
There was a bug in Unity where
TMP_TextUtilities.FindIntersectingLinkwouldn't work whenTextOverflowModesis set toTextOverflowModes.Link. More information in this bug thread.A workaround I used is to rewrite and fix the functionality of
FindIntersectingLinkin a custom class and use that instead, until Unity fixes the official one themselves. -
Images and videos will not work in editor since they being stripped from the game files. A solution would be to create a
Removable Assetsfolder in game for editor visualization. Add a deployment job to move that folder's content into theStreamableAssetsfolder to be hosted online just before the build begins.