예제 #1
0
    public static HeadlessProgress Init()
    {
        if (progressWindow == null)
        {
            progressWindow = EditorWindow.GetWindow <HeadlessProgress>(true);
        }

        stepList = new Dictionary <string, string>();

        stepList.Add("INIT", "Initializing...");
        stepList.Add("PREPROCESS", "Preparing build...");
        stepList.Add("BUILD", "Building...");
        stepList.Add("BACKUP", "Processing assets...");
        stepList.Add("POSTPROCESS", "Finalizing build...");
        stepList.Add("REVERT", "Applying settings...");

        Texture iconAsset = AssetDatabase.LoadAssetAtPath <Texture> (HeadlessExtensions.GetHeadlessBuilderPath(false) + "/Editor/Assets/Texture/icon.png");

        progressWindow.titleContent = new GUIContent("Headless Builder", iconAsset);

        progressWindow.minSize = new Vector2(300, 70);
        progressWindow.maxSize = new Vector2(300, 70);

        progressWindow.ShowUtility();
        HeadlessExtensions.CenterOnMainWin(progressWindow, 0);

        return(progressWindow);
    }
예제 #2
0
    static bool PlayBuild ()
    {
        try
        {
            if (debugBuild)
            {
                HeadlessProgress.Hide();
                HeadlessDebug.StartDebug();
            }

            return true;
        }
        catch (Exception e)
        {
            UnityEngine.Debug.LogError(e);
            return false;
        }
    }
예제 #3
0
	// BUILD STEPS:

	static bool InitializeBuild ()
	{
		try {

			HeadlessCallbacks.InvokeCallbacks ("HeadlessBuildBefore");

            if (manualBuild || debugBuild)
            {
                // Hide progress window if visible
                HeadlessProgress.Hide();
            }

            if (manualBuild) {
				// If this is a manual build, store the currently selected build target
				// so we can revert to that later
				regularTarget = EditorUserBuildSettings.activeBuildTarget;
				regularTargetGroup = BuildPipeline.GetBuildTargetGroup (regularTarget);
			}

			if (!batchBuild) {
				// Get the current build path for regular builds so we can use it as a default value
				try {
					buildPath = Directory.GetParent (EditorUserBuildSettings.GetBuildLocation (EditorUserBuildSettings.activeBuildTarget)).ToString ();
				} catch (Exception e) {
					if (e.Message.Equals ("never")) {
						// These errors are no problem at all, so we use this workaround to supress them
						UnityEngine.Debug.LogWarning (e);
					}
				}
			}

			if (manualBuild || debugBuild) {

                if (EditorApplication.isCompiling)
                {
                    EditorUtility.DisplayDialog("Headless Builder",
                        "You can't build while the editor is compiling.\n\n" +
                        "Please wait for compilation to finish and try again.", "OK");

                    return false;
                }

                if (EditorApplication.isPlaying)
                {
                    EditorUtility.DisplayDialog("Headless Builder",
                        "You can't build while the editor is in play mode.\n\n" +
                        "Please exit play mode by clicking the stop button and try again.", "OK");

                    return false;
                }

				if (headlessSettings.valueDummy && !headlessSettings.valueSkipConfirmation) {

					if (!EditorUtility.DisplayDialog ("Headless Builder",
						"You have enabled a feature that replaces your visual and audio assets with dummies.\n\n" +
						"This will greatly enhance your build's performance,\n" + 
						"but will also force Unity to re-import all assets, which might take a long time.\n\n" + 
						"Are you sure you want to continue?", "Yes", "Cancel")) {
					
						return false;

					}
				}

				if (headlessSettings.valueGI && 
					UnityEditor.EditorSettings.serializationMode != UnityEditor.SerializationMode.ForceText) {

					if (EditorUtility.DisplayDialog ("Headless Builder",
						"You have enabled a feature that requires Unity's serialization mode to be set to 'Force Text',\n" + 
						"but your current serialization mode is something else.\n\n" +
						"Should we change the serialization mode for you?\n" + 
						"This might take a long time.\n\n" + 
						"If you choose to not change the serialization mode, the relevant features will be skipped.", "Change to 'Force Text'", "Ignore")) {

						UnityEditor.EditorSettings.serializationMode = UnityEditor.SerializationMode.ForceText;

					}
				}


				// If this is a manual build, make sure the scene is saved, because we'll reload it later
				EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo ();

				for (int i = 0; i < EditorSceneManager.sceneCount; i++) {
					if (EditorSceneManager.GetSceneAt (i).isDirty) {
						UnityEngine.Debug.LogError ("Any changes to scenes must be changed before doing a headless build\nHeadless Builder (v" + Headless.version + ")");
						return false;
					}
				}

                if (manualBuild)
                {
                    // Get the build path used for previous headless builds and use it as a default, if there is any
                    bool foundPreviousPath = false;
                    if (headlessSettings.buildPath != null && headlessSettings.buildPath.Length > 3)
                    {
                        if (Directory.Exists(headlessSettings.buildPath))
                        {
                            buildPath = headlessSettings.buildPath;
                            foundPreviousPath = true;
                        }
                    }

                    // Ask output folder
                    if (!foundPreviousPath || !headlessSettings.valueRememberPath)
                    {
                        buildPath = EditorUtility.SaveFolderPanel("Choose Destination For Headless Build (" + headlessSettings.profileName + ")", buildPath, "");
                        if (buildPath.Length == 0)
                        {
                            UnityEngine.Debug.LogError("You must choose a destination path for the headless build\nHeadless Builder (v" + Headless.version + ")");
                            return false;
                        }
                    }
                }

			}

			// Set the build number
			headlessSettings.buildPath = buildPath;
            if (!debugBuild)
            {
                if (headlessSettings.buildID < int.MaxValue - 128)
                {
                    headlessSettings.buildID++;
                }
            }

            if (manualBuild || debugBuild)
            {
                // If this is a manual build, show the progress bar window
                progressWindow = HeadlessProgress.Init();
            }

            SetProgress ("INIT");

			return true;
		} catch (Exception e) {
			UnityEngine.Debug.LogError (e);
			return false;
		}

	}