HelpWindow.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace FAE
  6. {
  7. public class HelpWindow : EditorWindow
  8. {
  9. //Window properties
  10. private static int width = 440;
  11. private static int height = 300;
  12. private bool isTabInstallation = true;
  13. private bool isTabGettingStarted = false;
  14. private bool isTabSupport = false;
  15. [MenuItem("Help/Fantasy Adventure Environment", false, 0)]
  16. public static void ShowWindow()
  17. {
  18. EditorWindow editorWindow = EditorWindow.GetWindow<HelpWindow>(false, "About", true);
  19. editorWindow.titleContent = new GUIContent("Help " + FAE_Core.INSTALLED_VERSION);
  20. editorWindow.autoRepaintOnSceneChange = true;
  21. //Open somewhat in the center of the screen
  22. editorWindow.position = new Rect((Screen.width) / 2f, (Screen.height) / 2f, width, height);
  23. //Fixed size
  24. editorWindow.maxSize = new Vector2(width, height);
  25. editorWindow.minSize = new Vector2(width, 200);
  26. Init();
  27. editorWindow.Show();
  28. }
  29. private void SetWindowHeight(float height)
  30. {
  31. this.maxSize = new Vector2(width, height);
  32. this.minSize = new Vector2(width, height);
  33. }
  34. //Store values in the volatile SessionState
  35. static void Init()
  36. {
  37. FAE_Core.GetRootFolder();
  38. }
  39. void OnGUI()
  40. {
  41. DrawHeader();
  42. GUILayout.Space(5);
  43. DrawTabs();
  44. GUILayout.Space(5);
  45. EditorGUILayout.BeginVertical(EditorStyles.helpBox);
  46. if (isTabInstallation) DrawInstallation();
  47. if (isTabGettingStarted) DrawGettingStarted();
  48. if (isTabSupport) DrawSupport();
  49. //DrawActionButtons();
  50. EditorGUILayout.EndVertical();
  51. DrawFooter();
  52. }
  53. void DrawHeader()
  54. {
  55. EditorGUILayout.Space();
  56. EditorGUILayout.LabelField("<b><size=24>Fantasy Adventure Environment</size></b>", Header);
  57. GUILayout.Label("Version: " + FAE_Core.INSTALLED_VERSION, Footer);
  58. EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
  59. }
  60. void DrawTabs()
  61. {
  62. EditorGUILayout.BeginHorizontal();
  63. if (GUILayout.Toggle(isTabInstallation, "Installation", Tab))
  64. {
  65. isTabInstallation = true;
  66. isTabGettingStarted = false;
  67. isTabSupport = false;
  68. }
  69. if (GUILayout.Toggle(isTabGettingStarted, "Getting started", Tab))
  70. {
  71. isTabInstallation = false;
  72. isTabGettingStarted = true;
  73. isTabSupport = false;
  74. }
  75. if (GUILayout.Toggle(isTabSupport, "Support", Tab))
  76. {
  77. isTabInstallation = false;
  78. isTabGettingStarted = false;
  79. isTabSupport = true;
  80. }
  81. EditorGUILayout.EndHorizontal();
  82. }
  83. void DrawInstallation()
  84. {
  85. SetWindowHeight(335);
  86. EditorGUILayout.LabelField("Render pipeline conversion", EditorStyles.boldLabel);
  87. #if !UNITY_2019_3_OR_NEWER
  88. EditorGUILayout.HelpBox("Universal Render Pipeline support requires Unity 2019.3.7f1 or newer", MessageType.Info);
  89. #else
  90. if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null)
  91. {
  92. EditorGUILayout.HelpBox("No Scriptable Render Pipeline is currently active", MessageType.Warning);
  93. }
  94. EditorGUILayout.BeginHorizontal();
  95. {
  96. if (GUILayout.Button("<b><size=16>Built-in</size></b>\n<i>Amplify Shader Editor shaders</i>", Button))
  97. {
  98. FAE_Core.InstallShaders(FAE_Core.ShaderInstallation.BuiltIn);
  99. }
  100. using (new EditorGUI.DisabledGroupScope(UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null))
  101. {
  102. if (GUILayout.Button("<b><size=16>Universal RP</size></b>\n<i>Shader Graph shaders</i>", Button))
  103. {
  104. FAE_Core.InstallShaders(FAE_Core.ShaderInstallation.UniversalRP);
  105. }
  106. }
  107. }
  108. EditorGUILayout.EndHorizontal();
  109. EditorGUILayout.Space();
  110. using (new EditorGUILayout.HorizontalScope())
  111. {
  112. EditorGUILayout.HelpBox("Note: Grass shader for the URP is available on the Asset Store", MessageType.Info);
  113. if (GUILayout.Button("Open Asset Store", GUILayout.Height(40f), GUILayout.Width(120f)))
  114. {
  115. Application.OpenURL("com.unity3d.kharma:content/143830");
  116. }
  117. }
  118. #endif
  119. }
  120. void DrawGettingStarted()
  121. {
  122. SetWindowHeight(335);
  123. EditorGUILayout.HelpBox("Please view the documentation for further details about this package and its workings.", MessageType.Info);
  124. EditorGUILayout.Space();
  125. if (GUILayout.Button("<b><size=16>Online documentation</size></b>\n<i>Set up, best practices and troubleshooting</i>", Button))
  126. {
  127. Application.OpenURL(FAE_Core.DOC_URL + "#getting-started-3");
  128. }
  129. }
  130. void DrawSupport()
  131. {
  132. SetWindowHeight(350f);
  133. EditorGUILayout.BeginVertical(); //Support box
  134. EditorGUILayout.HelpBox("If you have any questions, or ran into issues, please get in touch!", MessageType.Info);
  135. EditorGUILayout.Space();
  136. //Buttons box
  137. EditorGUILayout.BeginHorizontal();
  138. if (GUILayout.Button("<b><size=12>Email</size></b>\n<i>Contact</i>", Button))
  139. {
  140. Application.OpenURL("mailto:contact@staggart.xyz");
  141. }
  142. if (GUILayout.Button("<b><size=12>Twitter</size></b>\n<i>Follow developments</i>", Button))
  143. {
  144. Application.OpenURL("https://twitter.com/search?q=staggart%20creations");
  145. }
  146. if (GUILayout.Button("<b><size=12>Forum</size></b>\n<i>Join the discussion</i>", Button))
  147. {
  148. Application.OpenURL(FAE_Core.FORUM_URL);
  149. }
  150. EditorGUILayout.EndHorizontal();//Buttons box
  151. EditorGUILayout.EndVertical(); //Support box
  152. }
  153. private void DrawActionButtons()
  154. {
  155. EditorGUILayout.Space();
  156. EditorGUILayout.BeginHorizontal();
  157. if (GUILayout.Button("<size=12>Rate</size>", Button))
  158. Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/account/downloads/search=");
  159. if (GUILayout.Button("<size=12>Review</size>", Button))
  160. Application.OpenURL("");
  161. EditorGUILayout.EndHorizontal();
  162. EditorGUILayout.Space();
  163. }
  164. private void DrawFooter()
  165. {
  166. //EditorGUILayout.Space();
  167. EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
  168. EditorGUILayout.Space();
  169. GUILayout.Label("- Staggart Creations -", Footer);
  170. }
  171. #region Styles
  172. private static GUIStyle _Footer;
  173. public static GUIStyle Footer
  174. {
  175. get
  176. {
  177. if (_Footer == null)
  178. {
  179. _Footer = new GUIStyle(EditorStyles.centeredGreyMiniLabel)
  180. {
  181. alignment = TextAnchor.MiddleCenter,
  182. wordWrap = true,
  183. fontSize = 12
  184. };
  185. }
  186. return _Footer;
  187. }
  188. }
  189. private static GUIStyle _Button;
  190. public static GUIStyle Button
  191. {
  192. get
  193. {
  194. if (_Button == null)
  195. {
  196. _Button = new GUIStyle(GUI.skin.button)
  197. {
  198. alignment = TextAnchor.MiddleLeft,
  199. stretchWidth = true,
  200. richText = true,
  201. wordWrap = true,
  202. padding = new RectOffset()
  203. {
  204. left = 14,
  205. right = 14,
  206. top = 8,
  207. bottom = 8
  208. }
  209. };
  210. }
  211. return _Button;
  212. }
  213. }
  214. private static GUIStyle _Header;
  215. public static GUIStyle Header
  216. {
  217. get
  218. {
  219. if (_Header == null)
  220. {
  221. _Header = new GUIStyle(GUI.skin.label)
  222. {
  223. richText = true,
  224. alignment = TextAnchor.MiddleCenter,
  225. wordWrap = true,
  226. fontSize = 18,
  227. fontStyle = FontStyle.Bold
  228. };
  229. }
  230. return _Header;
  231. }
  232. }
  233. private static Texture _HelpIcon;
  234. public static Texture HelpIcon
  235. {
  236. get
  237. {
  238. if (_HelpIcon == null)
  239. {
  240. _HelpIcon = EditorGUIUtility.FindTexture("d_UnityEditor.InspectorWindow");
  241. }
  242. return _HelpIcon;
  243. }
  244. }
  245. private static GUIStyle _Tab;
  246. public static GUIStyle Tab
  247. {
  248. get
  249. {
  250. if (_Tab == null)
  251. {
  252. _Tab = new GUIStyle(EditorStyles.miniButtonMid)
  253. {
  254. alignment = TextAnchor.MiddleCenter,
  255. stretchWidth = true,
  256. richText = true,
  257. wordWrap = true,
  258. fontSize = 12,
  259. fixedHeight = 30f,
  260. fontStyle = FontStyle.Bold,
  261. padding = new RectOffset()
  262. {
  263. left = 14,
  264. right = 14,
  265. top = 8,
  266. bottom = 8
  267. }
  268. };
  269. }
  270. return _Tab;
  271. }
  272. }
  273. #endregion //Stylies
  274. }//Window Class
  275. }