Testing is a core tenant I believe helps me produce high quality software. In order to have faith in a test suite that is assembled is to constantly verify every code change that is introduced to the system.
Github Actions (docs) is a wonderful workflow based system that can easily integrate with a Github project. Since Github is my version control repository of choice, it is natural for me to adopt it.
I lean heavily on Game.ci (docs), which is an open source project that uses containers and wizardry to produce Unity game builds.
Here is my default github actions definition for a unity project. There are assumptions that must be true
- The unity project files are a subdirectory (aka subfolder) of a directory named
unity
. This directory will be the watch directory. This isolation allows this workflow to only build if unity project files are touched (aka dirty). - This example uses my latest unity project
global-game-jam-2022
. If you are using vim, you can change the project name with this snippet:%s/UNITY_PROJECT_DIRECTORY_NAME/ your desired name here (remove spaces) /g
- Github Pages (docs) is enabled and is targeting a
docs
subdirectory in the root of the project folder. That is ultimately where some unity webGL build files will go. - This file needs to go in the
.github/workflows
directory. If you do not have it, runmkdir -p .github/workflows
to create it.
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19230417/Screen-Shot-2022-02-19-at-11.03.03-PM-1024x74.png)
This is the result of the file looks like this.
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19223639/Screen-Shot-2022-02-19-at-10.34.36-PM-1024x560.png)
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19223743/Screen-Shot-2022-02-19-at-10.35.07-PM.png)
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19223753/Screen-Shot-2022-02-19-at-10.35.12-PM.png)
My Default WebGL Template
Unity allows creators to define custom webGL templates (docs). Here is what I like to use myself. Remember that the WebGLTemplates
folder has to be inside a Unity project’s Assets
folder.
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19224633/Screen-Shot-2022-02-19-at-10.46.15-PM-1024x404.png)
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19225820/Screen-Shot-2022-02-19-at-10.57.53-PM-1024x865.png)
![](https://cdn.andrewallbright.com/wp-content/uploads/2022/02/19225203/Screen-Shot-2022-02-19-at-10.48.02-PM-1024x862.png)
From here it is easy to imagine how to extend the webGL template files to accommodate whatever web browser features you may want to utilize.