Esempio n. 1
0
    static void PrepareVariables()
    {
        headlessSettings = HeadlessEditor.LoadSettings(HeadlessProfiles.currentProfile, true);

        assetsFolder = NormalizePath(Application.dataPath);
        projectFolder = NormalizePath(Directory.GetParent(assetsFolder).ToString());
        dummyFolder = NormalizePath(HeadlessExtensions.GetHeadlessBuilderPath(true) + "/Editor/Assets/Dummy");

        Directory.CreateDirectory(projectFolder + "/headless_builder_backup");
        backupFolder = NormalizePath(projectFolder + "/headless_builder_backup");
    }
Esempio n. 2
0
    public static void FindProfiles()
    {
        Dictionary <string, string> newList = new Dictionary <string, string>();

        string[] profiles = AssetDatabase.FindAssets("HeadlessSettings");
        foreach (var guid in profiles)
        {
            string profilePath = AssetDatabase.GUIDToAssetPath(guid);
            if (profilePath.EndsWith(".asset"))
            {
                HeadlessSettings profileData = HeadlessEditor.LoadSettings(profilePath, false);
                newList.Add(profilePath, profileData.profileName);
            }
        }

        profileList = newList;
    }
Esempio n. 3
0
	static bool PreprocessBuild ()
	{

		try {

			// Save the settings cause we might have changed them
			// This will also propagate the runtime settings so they can be included in the build
			HeadlessEditor.SaveSettings (headlessSettings, HeadlessProfiles.currentProfile);

			System.IO.File.WriteAllText(backupFolder + "/lock.txt", "The existence of this file means that a backup was created and not (yet) reverted.");


			// Backup the graphics settings cause changing the platform sometimes modifies them
			BackupFile (projectFolder + "/ProjectSettings/GraphicsSettings.asset");

			if (headlessSettings.valueAudio) {
				// Disable audio if this feature is enabled in the settings

				BackupFile (projectFolder + "/ProjectSettings/AudioManager.asset");

				var audioManager = AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/AudioManager.asset") [0];
				var serializedManager = new SerializedObject (audioManager);
				var prop = serializedManager.FindProperty ("m_DisableAudio");
				prop.boolValue = true;
				serializedManager.ApplyModifiedProperties ();

				UnityEngine.Debug.Log ("Disabled audio rendering\nHeadless Builder (v" + Headless.version + ")");
			}

			if (headlessSettings.valueGI) {
				// Disable global illumination if this feature is enabled in the settings

				if (UnityEditor.EditorSettings.serializationMode == UnityEditor.SerializationMode.ForceText) {

					foreach (var sceneAsset in sceneAssets) {
						BackupFile (projectFolder + "/" + sceneAsset);
						ProcessScene (projectFolder + "/" + sceneAsset);
					}

					UnityEngine.Debug.Log ("Disabled global illumination\nHeadless Builder (v" + Headless.version + ")");

				} else {
					UnityEngine.Debug.LogWarning ("Disabling global illumination was skipped, because the serialization mode is not set to 'Force Text'\nHeadless Builder (v" + Headless.version + ")");
				}
			}

			if (!debugBuild && headlessSettings.valueDummy) {
				// Replace assets with dummies if this feature is enabled in the settings

				sizeOriginal = 0;
				sizeDummy = 0;
				replaceCount = 0;
				skipDummy = new List<string> ();

				Texture2D[] icons = PlayerSettings.GetIconsForTargetGroup (BuildTargetGroup.Unknown);
				foreach (Texture2D icon in icons) {
					skipDummy.Add (NormalizePath (projectFolder + "/" + AssetDatabase.GetAssetPath (icon)));
				}
				icons = PlayerSettings.GetIconsForTargetGroup (BuildPipeline.GetBuildTargetGroup (buildTarget));
				foreach (Texture2D icon in icons) {
					skipDummy.Add (NormalizePath (projectFolder + "/" + AssetDatabase.GetAssetPath (icon)));
				}

				FindDummies (dummyFolder);
				ProcessDirectory (assetsFolder);

				UnityEngine.Debug.Log ("Replaced " + replaceCount + " assets totaling " + (Mathf.Round (sizeOriginal / 1024 / 1024)) + " MB with " + (Mathf.Round (sizeDummy / 1024 / 1024)) + " MB worth of dummy files\nHeadless Builder (v" + Headless.version + ")");
			}


			// Backup the project settings to revert defines later
			BackupFile (projectFolder + "/ProjectSettings/ProjectSettings.asset");

			string symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildPipeline.GetBuildTargetGroup(buildTarget));
			string[] symbolArray = symbols.Split(new String[]{";"}, StringSplitOptions.None);
			if (!symbolArray.Contains("HEADLESS")) {
				symbols += ";HEADLESS";
			}
			if (!symbolArray.Contains("HEADLESS_" + headlessSettings.profileName.ToUpper())) {
				symbols += ";HEADLESS_" + headlessSettings.profileName.ToUpper();
			}
			PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildPipeline.GetBuildTargetGroup(buildTarget), symbols);


			// Reload the assets to reflect the changes
			AssetDatabase.Refresh ();

			if (manualBuild && currentScene.Length > 0) {
				// If this is a manual build, reload the scene if a scene was loaded
				EditorSceneManager.OpenScene (currentScene);
			}

			SetProgress ("BUILD");

			return true;
		} catch (Exception e) {
			UnityEngine.Debug.LogError (e);
			return false;
		}
	}
Esempio n. 4
0
    static void SelectAbout()
    {
        HeadlessEditor editor = EditorWindow.GetWindow <HeadlessEditor> ();

        editor.OnAbout();
    }
Esempio n. 5
0
    static void SelectDocumentation()
    {
        HeadlessEditor editor = EditorWindow.GetWindow <HeadlessEditor> ();

        editor.OnDocumentation();
    }
Esempio n. 6
0
    static void SelectSettings()
    {
        HeadlessEditor editor = EditorWindow.GetWindow <HeadlessEditor> ();

        editor.OnSettings();
    }