Skip to content

Instantly share code, notes, and snippets.

@Podshot
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Podshot/359200206f9262cc3ccd to your computer and use it in GitHub Desktop.
Save Podshot/359200206f9262cc3ccd to your computer and use it in GitHub Desktop.
A Builder script I created to build all OS releases together without a lot of clicking
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Stopwatch = System.Diagnostics.Stopwatch;
public class Builder {
private static string[] levels = new string[] {"Assets/<Scene File.unity>"};
private static string buildPath = Application.dataPath.Replace("Assets", "/")+"Builds/";
// This is project specific
// Change each key to the path/directory structure you prefer
private static Dictionary<string, BuildTarget> buildTypes = new Dictionary<string, BuildTarget>() {
{"Windows/<Windows 64bit Release.exe>", BuildTarget.StandaloneWindows64},
{"Windows/<Windows 32bit Release.exe>", BuildTarget.StandaloneWindows},
{"Mac/<OS X Universal Release.app>", BuildTarget.StandaloneOSXUniversal},
{"Linux/<Linux Universal Release.x86>", BuildTarget.StandaloneLinuxUniversal}
};
[MenuItem("Tools/Build Project", false, 1)]
private static void BuildProject() {
Stopwatch timer = new Stopwatch();
timer.Start();
foreach (KeyValuePair<string, BuildTarget> entry in buildTypes) {
if (File.Exists(buildPath + entry.Key)) {
File.Delete(buildPath + entry.Key);
}
Debug.Log("Building " + entry.Key);
BuildPipeline.BuildPlayer(levels,buildPath + entry.Key, entry.Value, BuildOptions.None);
}
timer.Stop();
Debug.Log("Building took: "+(timer.ElapsedMilliseconds/1000)+"s");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment