BuildInfo.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace XRTool.Util
  7. {
  8. public class BuildInfo
  9. {
  10. /// <inheritdoc />
  11. public virtual BuildTarget BuildTarget { get; }
  12. private string outputDirectory;
  13. /// <inheritdoc />
  14. public IEnumerable<string> Scenes { get; set; }
  15. private const string EDITOR_PREF_BUILD_DIR = "BuildDeployWindow_BuildDir";
  16. private const string EDITOR_PREF_INCREMENT_BUILD_VERSION = "BuildDeployWindow_IncrementBuildVersion";
  17. public static string BuildDirectory
  18. {
  19. get => $"{EditorPreferences.Get(EDITOR_PREF_BUILD_DIR, "Builds")}/{EditorUserBuildSettings.activeBuildTarget}";
  20. set => EditorPreferences.Set(EDITOR_PREF_BUILD_DIR, value.Replace($"/{EditorUserBuildSettings.activeBuildTarget}", string.Empty));
  21. }
  22. public string OutputDirectory
  23. {
  24. get => string.IsNullOrEmpty(outputDirectory) ? outputDirectory = BuildDirectory : outputDirectory;
  25. set => outputDirectory = value;
  26. }
  27. /*
  28. //buildReport = BuildPipeline.BuildPlayer(
  29. // buildInfo.Scenes.ToArray(),
  30. // buildInfo.OutputDirectory,
  31. // buildInfo.BuildTarget,
  32. // buildInfo.BuildOptions);
  33. */
  34. public BuildInfo()
  35. {
  36. BuildTarget = EditorUserBuildSettings.activeBuildTarget;
  37. Scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(scene => scene.path);
  38. }
  39. }
  40. }