Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UdpInstaller.cs 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using UnityEngine;
  3. using UnityEditor.PackageManager.UI;
  4. namespace UnityEditor.Purchasing
  5. {
  6. [Obsolete("UDP support will be removed in the next major update of In-App Purchasing. Right now, the UDP SDK will still function normally in tandem with IAP.")]
  7. /// <summary>
  8. /// This class directs the developer to install UDP if it is not already installed through Package Manager.
  9. /// </summary>
  10. public class UdpInstaller
  11. {
  12. private const string k_PackManWindowTitle = "Get UDP via Package Manager";
  13. private const string k_NoPackManWindowTitle = "UDP is no longer available in the Package Manager";
  14. private static readonly Vector2 k_WindowDims = new Vector2(480, 120);
  15. internal static void PromptUdpInstallation()
  16. {
  17. OpenUdpInstallationInstructionsWindow();
  18. }
  19. static void OpenUdpInstallationInstructionsWindow()
  20. {
  21. OpenUdpWindow<UdpInstallInstructionsWindow>(k_PackManWindowTitle);
  22. }
  23. static void OpenUdpWindow<TEditorWindow>(string title) where TEditorWindow : RichEditorWindow
  24. {
  25. var window = (TEditorWindow)EditorWindow.GetWindow(typeof(TEditorWindow));
  26. window.titleContent.text = title;
  27. window.minSize = k_WindowDims;
  28. window.Show();
  29. }
  30. internal static void PromptUdpUnavailability()
  31. {
  32. OpenUdpDeprecatedDisclaimerWindow();
  33. }
  34. static void OpenUdpDeprecatedDisclaimerWindow()
  35. {
  36. OpenUdpWindow<UdpDeprecatedDisclaimerWindow>(k_NoPackManWindowTitle);
  37. }
  38. }
  39. internal class UdpInstallInstructionsWindow : RichEditorWindow
  40. {
  41. private const string k_InfoText = "In order to use this functionality, you must install or update the Unity Distribution Portal Package. Would you like to begin?";
  42. private const string k_NotNowButtonText = "Not Now";
  43. private const string k_GoButtonText = "Go";
  44. private void OnGUI()
  45. {
  46. EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
  47. OnTextGui();
  48. OnButtonGui();
  49. EditorGUILayout.EndVertical();
  50. }
  51. void OnTextGui()
  52. {
  53. EditorGUILayout.BeginHorizontal();
  54. EditorGUILayout.BeginVertical();
  55. GUILayout.Label(k_InfoText, EditorStyles.wordWrappedLabel);
  56. EditorGUILayout.EndVertical();
  57. EditorGUILayout.EndHorizontal();
  58. }
  59. void OnButtonGui()
  60. {
  61. EditorGUILayout.BeginHorizontal();
  62. GUILayout.FlexibleSpace();
  63. if (GUILayout.Button(k_NotNowButtonText))
  64. {
  65. Close();
  66. }
  67. if (GUILayout.Button(k_GoButtonText))
  68. {
  69. GoToInstaller();
  70. Close();
  71. }
  72. EditorGUILayout.EndHorizontal();
  73. }
  74. static void GoToInstaller()
  75. {
  76. try
  77. {
  78. Window.Open(UnityPurchasingEditor.UdpPackageName);
  79. }
  80. catch (Exception exception)
  81. {
  82. Debug.LogWarning("Could not locate the Unity Distribution Portal package in package manager. It is now deprecated and you will need to install a local archived copy if you need these features.\nThe Package Manager sent this exception: " + exception.Message);
  83. }
  84. }
  85. }
  86. class UdpDeprecatedDisclaimerWindow : RichEditorWindow
  87. {
  88. const string k_InfoText = "In order to use this functionality, you must install or update the Unity Distribution Portal Package.\nUnfortunately, the package is now deprecated and is no longer hosted in the Unity Registry. You will need to obtain a local copy of it and install it manually.";
  89. const string k_CloseButtonText = "Close";
  90. private void OnGUI()
  91. {
  92. EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
  93. OnTextGui();
  94. OnButtonGui();
  95. EditorGUILayout.EndVertical();
  96. }
  97. void OnTextGui()
  98. {
  99. EditorGUILayout.BeginHorizontal();
  100. EditorGUILayout.BeginVertical();
  101. GUILayout.Label(k_InfoText, EditorStyles.wordWrappedLabel);
  102. EditorGUILayout.EndVertical();
  103. EditorGUILayout.EndHorizontal();
  104. }
  105. void OnButtonGui()
  106. {
  107. EditorGUILayout.BeginHorizontal();
  108. GUILayout.FlexibleSpace();
  109. if (GUILayout.Button(k_CloseButtonText))
  110. {
  111. Close();
  112. }
  113. EditorGUILayout.EndHorizontal();
  114. }
  115. }
  116. }