Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

BuildTargetGroupExtensions.cs 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using UnityEditor;
  6. using UnityEditor.Purchasing;
  7. using UnityEngine;
  8. using UnityEngine.Purchasing;
  9. static class BuildTargetGroupExtensions
  10. {
  11. internal static ReadOnlyCollection<string> ToAppStoreDisplayNames(this BuildTargetGroup value)
  12. {
  13. var stores = value.ToAppStores();
  14. var storeNames = stores.Select(store => store.ToDisplayName()).ToList();
  15. return storeNames.AsReadOnly();
  16. }
  17. internal static ReadOnlyCollection<AppStore> ToAppStores(this BuildTargetGroup value)
  18. {
  19. AppStore[] storesArray;
  20. switch (value)
  21. {
  22. case BuildTargetGroup.Android:
  23. {
  24. storesArray = ToAndroidAppStores(value);
  25. break;
  26. }
  27. case BuildTargetGroup.iOS:
  28. case BuildTargetGroup.tvOS:
  29. #if UNITY_VISIONOS
  30. case BuildTargetGroup.VisionOS:
  31. #endif
  32. storesArray = new[] { AppStore.AppleAppStore };
  33. break;
  34. case BuildTargetGroup.WSA:
  35. storesArray = new[] { AppStore.WinRT };
  36. break;
  37. case BuildTargetGroup.Standalone:
  38. if (Application.platform == RuntimePlatform.OSXEditor)
  39. {
  40. storesArray = new[] { AppStore.MacAppStore };
  41. break;
  42. }
  43. goto default;
  44. default:
  45. storesArray = new[] { AppStore.fake };
  46. break;
  47. }
  48. return Array.AsReadOnly(storesArray);
  49. }
  50. static AppStore[] ToAndroidAppStores(this BuildTargetGroup value)
  51. {
  52. if (value != BuildTargetGroup.Android)
  53. {
  54. return new AppStore[0];
  55. }
  56. var stores = new List<AppStore>();
  57. for (var store = (AppStore)AppStoreMeta.AndroidStoreStart;
  58. store <= (AppStore)AppStoreMeta.AndroidStoreEnd;
  59. ++store)
  60. {
  61. stores.Add(store);
  62. }
  63. return stores.ToArray();
  64. }
  65. internal static string ToPlatformDisplayName(this BuildTargetGroup value)
  66. {
  67. switch (value)
  68. {
  69. case BuildTargetGroup.iOS:
  70. {
  71. // TRICKY: Prefer an "iOS" string on BuildTarget, to avoid the unwanted "BuildTargetGroup.iPhone"
  72. return BuildTarget.iOS.ToString();
  73. }
  74. case BuildTargetGroup.Standalone:
  75. {
  76. switch (EditorUserBuildSettings.activeBuildTarget)
  77. {
  78. case BuildTarget.StandaloneOSX:
  79. return "macOS";
  80. case BuildTarget.StandaloneWindows:
  81. return "Windows";
  82. default:
  83. return BuildTargetGroup.Standalone.ToString();
  84. }
  85. }
  86. default:
  87. return value.ToString();
  88. }
  89. }
  90. }