Have Unity open while building
You know how Unity doesn’t let you do anything to the project while it’s building? It just shows a progress bar. Even more frustrating, on Android builds, it forces you to wait while it pushes the APK onto the device, for which there’s no real reason.
Command line builds will help you out a bit, but they will also error and fail if you have the project open. You could keep a copy of the project, but then it’d have to be synced, and that’s just terrible.
This solution works on both Windows and OSX, but I only have sample code for Windows. This example sets up a parallel Android build.
TL:DR; place symlinks for ProjectSettings and Assets in a (sub)folder, and then build that instead of your project.
1. Setup symlinks
A symlink is like a ‘fake’ directory that upon visiting will show you the files of another directory. Not a copy, but the real physical files, just through another address than normally. Open an elevated CMD (run as administrator), go to your project directory, and type these commands:
MD TempBuild MKLINK /D “%cd%\TempBuild\Assets” “%cd%\Assets” MKLINK /D “%cd%\TempBuild\ProjectSettings” “%cd%\ProjectSettings”
Should look like this:
2. Setup the build system in Unity
Make a new script called AutoBuild.cs (or whatever, name doesn’t matter) and put the following function in:
static void PerformBuild() { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); BuildPipeline.BuildPlayer( EditorBuildSettings.scenes, "Bin\yourproject.apk", BuildTarget.Android); }
Make sure the Bin folder exists, build will fail silently if it doesn’t.
3. Create command line build script
Make a build.bat file in your project root with this in it
RMDIR /s /q TempBuild\Bin MD TempBuild\Bin CD TempBuild
Unity -quit -batchmode -projectPath %cd% -executeMethod Autobuild.PerformBuild -logFile buildlog.log
ADB uninstall com.yourproject ADB install Bin\yourproject.apk ADB shell am start -n com.yourproject/com.unity.UnityPlayerActivity
4. Make it into a menu-item in Unity
You can dump this into AutoBuild.cs, or any other script:
//you’ll need using System.Diagnostics
[MenuItem("JoonIsAmazing/Build Android Parallel")] static public void BuildAndroidParallel() { Process myProcess = new Process(); myProcess.StartInfo.FileName = Application.dataPath + "/build.bat"; myProcess.StartInfo.WorkingDirectory = Application.dataPath; myProcess.Start(); }
Let me know on Twitter if you’re stuck (@joonturbo)











