Thank you for purchasing Hdg Build!
Import the Hdg Build .unitypackage file into your project. Once imported, the source code should appear in:
Assets/Editor/HdgBuild
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.
Select the Build Config Collection asset you just created.
This will show the Build Config Collection in the inspector window:
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:
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.
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.
You can also use your build configurations from your own build scripts. For example:
public static void MakeiOSBuild()
{
Hdg.BuildConfigManager.Build("Build", "BuildConfigCollection", "iOS Release");
}
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:
public static void MakeBuild()
{
var buildConfig = "";
var buildPlatform = "";
foreach (var arg in Environment.GetCommandLineArgs())
{
if (arg.StartsWith("-build_config"))
{
var setting = arg.Split('=');
buildConfig = setting[1];
}
else if (arg.StartsWith("-build_platform"))
{
var setting = arg.Split('=');
buildPlatform = setting[1];
}
}
var buildConfigName = string.Format("{0} {1}", buildPlatform, buildConfig);
Debug.Log(string.Format("Building '{0}'..", buildConfigName));
Hdg.BuildConfigManager.Build("Build", "BuildConfigCollection", buildConfigName);
}
This is useful when making builds from a continuous build server.
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.
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.
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
:
using UnityEditor;
public static class PreBuild
{
[Hdg.PreBuild]
static void DoPreBuild(BuildTarget buildTarget, string outputPath)
{
// ...
}
}
This method will be called immediately before the build begins.
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