Getting Started

Thank you for purchasing Hdg Build!

Installation

Import the Hdg Build .unitypackage file into your project. Once imported, the source code should appear in:

Assets/Editor/HdgBuild

Usage

1. Create a new Build Config Collection

In the Project window, in an appropriate folder (e.g. the root Assets folder), right click and select Create > Build Config Collection.

A Build Config Collection is just a Unity asset. It is where you will define your build configurations. The default name is BuildConfigCollection but you can rename it if you like.

2. Select the Build Config Collection asset

Select the Build Config Collection asset you just created.

This will show the Build Config Collection in the inspector window:

3. Add a build config

Click the plus button in the bottom right of the Build Config Collection inspector to create a new build configuration.

This will add a new build configuration and automatically select it:

4. Edit build settings

In the inspector window you can change various properties for this build configuration. For example:

In the above example, we have called the build configuration Windows Release. When this build configuration is built, the symbols RELEASE and DISABLE_CHEATS will be defined, and a scene called Test will be built.

To add all scenes that are currently enabled in the Unity Build Settings window, click the Add All Scenes button:

If no scenes are configured for a build configuration, Hdg Build will build all scenes that are enabled in the Unity Build Settings.

5. Use the build configurations in the editor

Once your build configurations are set up, you can build them from the inspector with the Build button, or switch to them with the Switch button:

Note that Switch will do the same thing as switching platforms in the Build Settings window (i.e. Unity will re-import your project). Switching to a build config will also apply the defines specified in the build configuration.

6. Use the build configurations in build scripts

You can also use your build configurations from your own build scripts. For example:

The above will build the iOS Release build configuration from the BuildConfigCollection in the Assets folder. The iOS output folder will be called Build.

This is even more powerful if you pass in the build configuration via the system environment or the command-line:

This is useful when making builds from a continuous build server.

API Notes

The Hdg.BuildConfigManager class (in BuildConfigManager.cs) contains a set of static methods for accessing the build configurations and for performing builds. Note that several methods take a path to the Build Config Collection; this path should be specified relative to the Assets folder.

Building

The Build method can be used to perform a build. If the specified build configuration does not contain any scenes, Build will build all scenes that are enabled in Unity’s EditorBuildSettings.

Build calls Unity’s BuildPipeline.BuildPlayer method and returns its result. On Unity 2018.1 or newer, this is a BuildReport instance. On previous versions this is an error string.

The meaning of the output path for Build depends on the platform that is being built. For example, for iOS the output path is a folder, and for Windows the output path is an executable name.

Unity’s build pipeline processing callbacks can also be used like normal.

Pre-build Callbacks

Prior to Unity 5.6 the IPreprocessBuild callbacks did not exist. Thus if you wish to do some preprocessing or call some methods before the build begins, Hdg Build provides a PreBuild attribute. This attribute can be applied to any static method that accepts a BuildTarget and a string:

This method will be called immediately before the build begins.

Contact Information

For bug reports, suggestions, or more information email us at support@horsedrawngames.com.

You can also post support questions on our thread on the Unity forums.

Copyright Horse Drawn Games Pty Ltd 2018