Publish Builds in Unity ECS

Workflow for deploying project using Unity's new Build Configurations

What you'll develop on this page

We will be able to deploy our project using Unity's new build pipeline.

Github branch link: https://github.com/moetsi/Unity-DOTS-Multiplayer-XR-Sample/tree/Building-the-Project/

Creating a build configuration

First, some background:

Before DOTS, the way to build a project was to go to "File" and choose "Build Settings" and set up the build.

But now with SubScenes, this process no longer works. We need to create Build Configurations and build our projects from there. This is because we are using a new build pipeline built for DOTS projects. The previous method is for MonoBehaviour projects. We will be using a hybrid approach, but because we use DOTS, we must use this new build process.

These Build Configurations have some great benefits where you can define a "base" Build Configuration, and have platform specific builds inherit from the base build. So if you add a new scene to your project, rather than having to add the new scene to every Build Configuration for each platform, you can add the new scene to your "base" Build Configuration and it will be included in each inherited Build Configuration.

  • We are going to add a new line to our package manifest

"com.unity.platforms": "0.50.0-preview.4",
  • We can now see new options to create Build Configurations when we right-click and hit "create"

  • Create a BuildSettings folder with in the Assets folder

  • Navigate to the BuildSettings folder and create an "Empty Build Configuration" and name it "Base"

    • This is the "base" Build Configuration that platform-specific builds will inherit from

  • Add a "General Settings" component to Base

    • In General Settings, update the Company Name and Product Name fields

  • And a "Scene List" component

    • Drop down the Scene Infos menu and click "Add Element"

    • Drag in SampleScene into the Scene field under Element name, and check Auto Load

  • Hit "apply" to save the changes

This is our "base" information that we will apply to all different builds for different platforms. (We promise that will make sense in a second).

  • Now right click in /BuildSettings, choose "create", then "Build" and create a new "Empty Build Configuration"

    • Name it "Windows" or "MacOS" based on your development environment

  • Select the newly created Build Configuration and click "Add Component", select "Classic Build Profile" and choose Windows/Mac from the dropdown

  • Click "+ Add Configuration" under Shared Configurations at the top of the Inspector than drag "Base" into the Shared Configuration field

  • You will see that we have inherited the General Settings and Scene List from Base

  • Hit "apply" at the bottom of Inspector and then click "Build and Run" at the top of the Inspector

  • Great, now we know how to build a Base Build Configuration and inherit to platform-specific Builds

  • Rather than having to make these ourselves for each and every platform, let's instead grab all the pre-made Build Configurations that Unity has created

  • Delete our "Base" and MacOS/Windows Build Configuration from our Build Settings folder and replace them with our downloaded Build Configurations

    • Download each of the Build Configuration files in Unity's EntityComponentSystemSamples repo by cloning the repo or downloading a zip, etc. and dragging the files into the BuildSettings folder in your Project folder

      • FYI: If you downloaded the full Unity ECS Samples repo, the BuildConfigurations files are under ECSSamples > Assets > BuildConfigurations

  • Update the Product Name and Company Name fields in "BaseBuildConfiguration" General Settings and drag in SampleScene to Scene under Scene List

  • Now select a build configuration for your development platform

    • If you are developing on Mac you would choose "macOS-Build"

    • Click "+ Add Configuration" under Shared Configurations at the top of the Inspector

    • Drag "BaseBuildConfiguration" into the Shared Configuration field (drag gently, so that macOS-Build stays selected)

      • You will see that we have inherited the General Settings and Scene List from Base

      • Hit "apply" at the bottom of Inspector and then click "Build and Run" at the top of the Inspector

  • Hit "Build and Run" in Inspector

    • The first time you hit build and run you may encounter an error, don't worry that is Unity getting ready to build, hit it again and you will be set

We can now build for specific target platforms

  • We created a BuildSettings folder in Assets and added Build Configurations

  • We updated our Base Build Configuration and applied so all platform-specific Build Configurations would be updated

Github branch link: https://github.com/moetsi/Unity-DOTS-Multiplayer-XR-Sample/tree/Building-the-Project/

git clone https://github.com/moetsi/Unity-DOTS-Multiplayer-XR-Sample/ git checkout 'Building-the-Project'

Last updated