// This function cleans a build up in a synchronized fashion // and is called regardless of whether the build was successful static void FinalizeBuildSync (bool restore) { if (restore) { try { RestoreBuild (); } catch (Exception e) { buildError = true; UnityEngine.Debug.LogError (e); } try { RevertBuild (); } catch (Exception e) { buildError = true; UnityEngine.Debug.LogError (e); } } if (buildError) { UnityEngine.Debug.LogError ("Build failed!\nHeadless Builder (v" + Headless.version + ")"); Headless.SetBuildingHeadless (false, HeadlessProfiles.currentProfile); HeadlessCallbacks.InvokeCallbacks ("HeadlessBuildFailed"); if (manualBuild || debugBuild) { SetProgress(null); } } else { UnityEngine.Debug.Log ("Build success!\nHeadless Builder (v" + Headless.version + ")"); Headless.SetBuildingHeadless(false, HeadlessProfiles.currentProfile); if (manualBuild || debugBuild) { SetProgress(null); } int finishedBuilds = EditorPrefs.GetInt ("HEADLESSBUILDER_FINISHEDBUILDS", 0); if (finishedBuilds < int.MaxValue - 64) { EditorPrefs.SetInt ("HEADLESSBUILDER_FINISHEDBUILDS", finishedBuilds + 1); } } if (queueBuild) { if (!buildError) { ManualBuildQueue (queueID + 1); } } }
// This function overarches the entire build process private static void Build () { buildError = false; if (batchBuild) { // Process the relevant command line arguments string[] args = System.Environment.GetCommandLineArgs (); string batchPath = null; string batchProfile = null; for (int i = 0; i < args.Length - 1; i++) { if (args [i] == "-headlessPath") { batchPath = args [i + 1]; } if (args [i] == "-headlessProfile") { batchProfile = args [i + 1]; } } if (batchPath != null && Directory.Exists (batchPath)) { buildPath = batchPath; } else { UnityEngine.Debug.LogError ("Use the -headlessPath command line parameter to set a valid destination path for the headless build\nHeadless Builder (v" + Headless.version + ")"); return; } if (batchProfile != null) { bool found = false; HeadlessProfiles.FindProfiles (); foreach (KeyValuePair<string,string> profile in HeadlessProfiles.GetProfileList()) { if (profile.Value.Equals (batchProfile)) { found = true; HeadlessProfiles.SetProfile (profile.Key); } } if (!found) { UnityEngine.Debug.LogError ("The profile specified by the -headlessProfile command line parameter was not found\nHeadless Builder (v" + Headless.version + ")"); return; } } } if (manualBuild || debugBuild) { if (!EditorWindow.GetWindow<HeadlessEditor>().IsDocked()) { EditorWindow.GetWindow<HeadlessEditor>().Close(); } } // Load the settings (from file, not from memory) PrepareVariables(); Headless.SetBuildingHeadless (true, headlessSettings.profileName); bool asyncExecute = manualBuild || debugBuild; if (asyncExecute) { HeadlessRoutine.start (InnerBuildAsync ()); } else { InnerBuildSync (); } }