Hosting a Unity WebGL game on the Internet Computer
This sample project demonstrates how to deploy a simple Unity WebGL game on the Internet Computer. The sample code is available at the examples repository.
Deploy a Unity WebGL build to IC
Let’s create a Unity WebGL build, and set it up to deploy with dfx. Before you begin, make sure you have DFX SDK, Unity installed.
Create a Unity WebGL build
- Create a new Unity Project with
Universal Render Pipelinetemplate selected - Switch to
WebGLbuild target in theBuild Settingswindow - Under the
Settings for WebGLtab in thePlayer Settingswindow- Set
Compression FormattoDisabledfor now - Choose the
MinimalWebGL template to reduce the number of files generated
- Set
- Build to WebGL in the
Build Settingswindow
Create a DFX project
Since there is no backend in this sample, there is not any benefit of using the dfx new project_name command to set up a template. The dfx.json file is all that is needed.
- Create a folder named
unity-webgl-sample - Create a
dfx.jsonunderunity-webgl-samplefolder - Follow the Unity WebGL sample to
- Setup the
dfx.jsonfile - Deploy the Unity WebGL build you generate in previous step
- Setup the
Deployment
The local network is started by running this command from the root of the DFX project:
$ dfx start --background
When the local network is up and running, run this command to deploy the canisters:
$ dfx deploy