Skip to content

Instantly share code, notes, and snippets.

@ArthurD
Created March 18, 2021 19:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArthurD/954a7b4dbc1eece53ec75e6024d1b8aa to your computer and use it in GitHub Desktop.
Save ArthurD/954a7b4dbc1eece53ec75e6024d1b8aa to your computer and use it in GitHub Desktop.
Build Code Example
private static void RunBuildsExample() {
// Build Each Target 1X / Branch
while(BuildTargets.Count > 0) {
var target = BuildTargets[0];
BuildTargets.RemoveAt(0);
foreach(var branch in Branches(optionsMask)) {
MakeOneBuild(buildDate, optionsMask, branch, target);
}
}
}
private static void MakeOneBuild(DateTime buildDate, int optionsMask, Branch branch, BuildTarget target) {
// Build Date, Scripting Defines
PlayerSettings.bundleVersion = BuildDate.ToString(buildDate);
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, ScriptingDefines(optionsMask, branch));
// If !DryRun -- DO IT!
if (!BuildMakerWindow.isProperty(BuildMakerWindow.BProp.DRY_RUN, optionsMask)) {
// Set Build Target
if(EditorUserBuildSettings.activeBuildTarget != target)
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, target);
// Handle Addressables, which are actually Asset Bundles.
AddressableAssetSettings.CleanPlayerContent();
AddressableAssetSettings.BuildPlayerContent();
// Build it
BuildPipeline.BuildPlayer(Scenes, FullPathForSingleBuild(buildDate, branch, target), target, GetBuildOptions(optionsMask));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment