MPUIKitUtilityWindow.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System.IO;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace MPUIKIT.Editor
  5. {
  6. public class MPUIKitUtilityWindow : EditorWindow
  7. {
  8. private static SerializedObject _graphicsSettingsObj;
  9. private static bool _setup;
  10. private static bool _alreadyShownOnStartup;
  11. private bool _initialized;
  12. private string _version = "Version: 1.2.0";
  13. private static bool _setupIsRequired;
  14. private static UnityEditor.Editor _settingsEditor;
  15. [MenuItem("Window/MPUIKit/Utility Panel")]
  16. public static void ShowWindow()
  17. {
  18. EditorWindow window = GetWindow<MPUIKitUtilityWindow>(true, "MPUIKit Utility Panel", true);
  19. window.minSize = new Vector2(400, 400);
  20. window.maxSize = new Vector2(400, 400);
  21. }
  22. private void OnGUI()
  23. {
  24. TopBannerGUI();
  25. WelcomeGUI();
  26. UtilButtonsGUI();
  27. BottomBarGUI();
  28. }
  29. private static void TopBannerGUI()
  30. {
  31. Rect headingRect = new Rect(0, 0, EditorGUIUtility.currentViewWidth, EditorGUIUtility.singleLineHeight * 5);
  32. Rect backgroundTexCoords = new Rect(0, 0, headingRect.width / headingRect.height, 1);
  33. Texture background = MPEditorContents.Background;
  34. background.wrapMode = TextureWrapMode.Repeat;
  35. GUI.DrawTextureWithTexCoords(headingRect, background, backgroundTexCoords);
  36. float height = headingRect.height;
  37. float width = headingRect.width - height - 30;
  38. Rect titleRect = new Rect(headingRect.width - width - 5, 20, width, height - 30);
  39. GUI.DrawTexture(titleRect, MPEditorContents.Title, ScaleMode.ScaleToFit);
  40. Rect textureRect = headingRect;
  41. textureRect.x = 0;
  42. textureRect.width = textureRect.height - 7;
  43. textureRect.height -= 7;
  44. GUI.DrawTexture(textureRect, MPEditorContents.Logo, ScaleMode.ScaleToFit);
  45. GUILayout.Space(headingRect.height + 20);
  46. }
  47. private static void WelcomeGUI()
  48. {
  49. var style = new GUIStyle(GUI.skin.label) {alignment = TextAnchor.MiddleCenter};
  50. EditorGUILayout.LabelField("Thank you for using", style, GUILayout.ExpandWidth(true));
  51. EditorGUILayout.LabelField("Modern Procedural UI Kit", style, GUILayout.ExpandWidth(true));
  52. GUILayout.Space(20);
  53. }
  54. private static void UtilButtonsGUI()
  55. {
  56. GUILayout.Space(6);
  57. Rect buttonRect = EditorGUILayout.GetControlRect(false, 40 * 3 + 4);
  58. buttonRect.width = (buttonRect.width / 2) - 1;
  59. buttonRect.height = 40;
  60. if (GUI.Button(buttonRect, "Documentation"))
  61. {
  62. Application.OpenURL("https://scrollbie.com/documentations/mpuikit-docs/");
  63. }
  64. buttonRect.x += buttonRect.width + 2;
  65. if (GUI.Button(buttonRect, "Website"))
  66. {
  67. Application.OpenURL("https://scrollbie.com/mpuikit/");
  68. }
  69. buttonRect.y += 42;
  70. buttonRect.x -= buttonRect.width + 2;
  71. if (GUI.Button(buttonRect, "Email"))
  72. {
  73. Application.OpenURL("mailto:support@scrollbie.com");
  74. }
  75. buttonRect.x += buttonRect.width + 2;
  76. if (GUI.Button(buttonRect, "Forum"))
  77. {
  78. Application.OpenURL(
  79. "https://forum.unity.com/threads/an-advanced-procedural-ui-generation-tool-create-modify-animate-spriteless-ui-even-at-runtime.846772");
  80. }
  81. buttonRect.y += 42;
  82. buttonRect.x -= buttonRect.width + 2;
  83. if (GUI.Button(buttonRect, "Changelog"))
  84. {
  85. Application.OpenURL("https://scrollbie.com/mpuikit/changelog.html");
  86. }
  87. buttonRect.x += buttonRect.width + 2;
  88. if (GUI.Button(buttonRect, "Other Assets"))
  89. {
  90. Application.OpenURL("https://assetstore.unity.com/publishers/29536");
  91. }
  92. if (GUILayout.Button("★ Rate/Review MPUIKit", GUILayout.ExpandWidth(true), GUILayout.Height(40)))
  93. {
  94. Application.OpenURL("https://assetstore.unity.com/packages/slug/163041");
  95. }
  96. }
  97. private void BottomBarGUI()
  98. {
  99. EditorGUILayout.BeginVertical();
  100. {
  101. GUILayout.FlexibleSpace();
  102. EditorGUILayout.BeginHorizontal();
  103. {
  104. EditorGUILayout.LabelField("© Copyright 2020 Scrollbie Studio", EditorStyles.miniLabel);
  105. GUIStyle style = new GUIStyle(EditorStyles.miniLabel);
  106. style.alignment = TextAnchor.MiddleRight;
  107. GUILayout.FlexibleSpace();
  108. EditorGUILayout.LabelField(_version, style, GUILayout.Width(120));
  109. }
  110. EditorGUILayout.EndHorizontal();
  111. }
  112. EditorGUILayout.EndVertical();
  113. }
  114. }
  115. }