123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEditor;
- using UnityEngine;
- namespace FAE
- {
- public class HelpWindow : EditorWindow
- {
- //Window properties
- private static int width = 440;
- private static int height = 300;
- private bool isTabInstallation = true;
- private bool isTabGettingStarted = false;
- private bool isTabSupport = false;
- [MenuItem("Help/Fantasy Adventure Environment", false, 0)]
- public static void ShowWindow()
- {
- EditorWindow editorWindow = EditorWindow.GetWindow<HelpWindow>(false, "About", true);
- editorWindow.titleContent = new GUIContent("Help " + FAE_Core.INSTALLED_VERSION);
- editorWindow.autoRepaintOnSceneChange = true;
- //Open somewhat in the center of the screen
- editorWindow.position = new Rect((Screen.width) / 2f, (Screen.height) / 2f, width, height);
- //Fixed size
- editorWindow.maxSize = new Vector2(width, height);
- editorWindow.minSize = new Vector2(width, 200);
- Init();
- editorWindow.Show();
- }
- private void SetWindowHeight(float height)
- {
- this.maxSize = new Vector2(width, height);
- this.minSize = new Vector2(width, height);
- }
- //Store values in the volatile SessionState
- static void Init()
- {
- FAE_Core.GetRootFolder();
- }
- void OnGUI()
- {
- DrawHeader();
- GUILayout.Space(5);
- DrawTabs();
- GUILayout.Space(5);
- EditorGUILayout.BeginVertical(EditorStyles.helpBox);
- if (isTabInstallation) DrawInstallation();
- if (isTabGettingStarted) DrawGettingStarted();
- if (isTabSupport) DrawSupport();
- //DrawActionButtons();
- EditorGUILayout.EndVertical();
- DrawFooter();
- }
- void DrawHeader()
- {
- EditorGUILayout.Space();
- EditorGUILayout.LabelField("<b><size=24>Fantasy Adventure Environment</size></b>", Header);
- GUILayout.Label("Version: " + FAE_Core.INSTALLED_VERSION, Footer);
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- }
- void DrawTabs()
- {
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Toggle(isTabInstallation, "Installation", Tab))
- {
- isTabInstallation = true;
- isTabGettingStarted = false;
- isTabSupport = false;
- }
- if (GUILayout.Toggle(isTabGettingStarted, "Getting started", Tab))
- {
- isTabInstallation = false;
- isTabGettingStarted = true;
- isTabSupport = false;
- }
- if (GUILayout.Toggle(isTabSupport, "Support", Tab))
- {
- isTabInstallation = false;
- isTabGettingStarted = false;
- isTabSupport = true;
- }
- EditorGUILayout.EndHorizontal();
- }
- void DrawInstallation()
- {
- SetWindowHeight(335);
- EditorGUILayout.LabelField("Render pipeline conversion", EditorStyles.boldLabel);
- #if !UNITY_2019_3_OR_NEWER
- EditorGUILayout.HelpBox("Universal Render Pipeline support requires Unity 2019.3.7f1 or newer", MessageType.Info);
- #else
- if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null)
- {
- EditorGUILayout.HelpBox("No Scriptable Render Pipeline is currently active", MessageType.Warning);
- }
- EditorGUILayout.BeginHorizontal();
- {
- if (GUILayout.Button("<b><size=16>Built-in</size></b>\n<i>Amplify Shader Editor shaders</i>", Button))
- {
- FAE_Core.InstallShaders(FAE_Core.ShaderInstallation.BuiltIn);
- }
- using (new EditorGUI.DisabledGroupScope(UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset == null))
- {
- if (GUILayout.Button("<b><size=16>Universal RP</size></b>\n<i>Shader Graph shaders</i>", Button))
- {
- FAE_Core.InstallShaders(FAE_Core.ShaderInstallation.UniversalRP);
- }
- }
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.Space();
- using (new EditorGUILayout.HorizontalScope())
- {
- EditorGUILayout.HelpBox("Note: Grass shader for the URP is available on the Asset Store", MessageType.Info);
- if (GUILayout.Button("Open Asset Store", GUILayout.Height(40f), GUILayout.Width(120f)))
- {
- Application.OpenURL("com.unity3d.kharma:content/143830");
- }
- }
- #endif
- }
- void DrawGettingStarted()
- {
- SetWindowHeight(335);
- EditorGUILayout.HelpBox("Please view the documentation for further details about this package and its workings.", MessageType.Info);
- EditorGUILayout.Space();
- if (GUILayout.Button("<b><size=16>Online documentation</size></b>\n<i>Set up, best practices and troubleshooting</i>", Button))
- {
- Application.OpenURL(FAE_Core.DOC_URL + "#getting-started-3");
- }
- }
- void DrawSupport()
- {
- SetWindowHeight(350f);
- EditorGUILayout.BeginVertical(); //Support box
- EditorGUILayout.HelpBox("If you have any questions, or ran into issues, please get in touch!", MessageType.Info);
- EditorGUILayout.Space();
- //Buttons box
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("<b><size=12>Email</size></b>\n<i>Contact</i>", Button))
- {
- Application.OpenURL("mailto:contact@staggart.xyz");
- }
- if (GUILayout.Button("<b><size=12>Twitter</size></b>\n<i>Follow developments</i>", Button))
- {
- Application.OpenURL("https://twitter.com/search?q=staggart%20creations");
- }
- if (GUILayout.Button("<b><size=12>Forum</size></b>\n<i>Join the discussion</i>", Button))
- {
- Application.OpenURL(FAE_Core.FORUM_URL);
- }
- EditorGUILayout.EndHorizontal();//Buttons box
- EditorGUILayout.EndVertical(); //Support box
- }
- private void DrawActionButtons()
- {
- EditorGUILayout.Space();
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("<size=12>Rate</size>", Button))
- Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/account/downloads/search=");
- if (GUILayout.Button("<size=12>Review</size>", Button))
- Application.OpenURL("");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.Space();
- }
- private void DrawFooter()
- {
- //EditorGUILayout.Space();
- EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
- EditorGUILayout.Space();
- GUILayout.Label("- Staggart Creations -", Footer);
- }
- #region Styles
- private static GUIStyle _Footer;
- public static GUIStyle Footer
- {
- get
- {
- if (_Footer == null)
- {
- _Footer = new GUIStyle(EditorStyles.centeredGreyMiniLabel)
- {
- alignment = TextAnchor.MiddleCenter,
- wordWrap = true,
- fontSize = 12
- };
- }
- return _Footer;
- }
- }
- private static GUIStyle _Button;
- public static GUIStyle Button
- {
- get
- {
- if (_Button == null)
- {
- _Button = new GUIStyle(GUI.skin.button)
- {
- alignment = TextAnchor.MiddleLeft,
- stretchWidth = true,
- richText = true,
- wordWrap = true,
- padding = new RectOffset()
- {
- left = 14,
- right = 14,
- top = 8,
- bottom = 8
- }
- };
- }
- return _Button;
- }
- }
- private static GUIStyle _Header;
- public static GUIStyle Header
- {
- get
- {
- if (_Header == null)
- {
- _Header = new GUIStyle(GUI.skin.label)
- {
- richText = true,
- alignment = TextAnchor.MiddleCenter,
- wordWrap = true,
- fontSize = 18,
- fontStyle = FontStyle.Bold
- };
- }
- return _Header;
- }
- }
- private static Texture _HelpIcon;
- public static Texture HelpIcon
- {
- get
- {
- if (_HelpIcon == null)
- {
- _HelpIcon = EditorGUIUtility.FindTexture("d_UnityEditor.InspectorWindow");
- }
- return _HelpIcon;
- }
- }
- private static GUIStyle _Tab;
- public static GUIStyle Tab
- {
- get
- {
- if (_Tab == null)
- {
- _Tab = new GUIStyle(EditorStyles.miniButtonMid)
- {
- alignment = TextAnchor.MiddleCenter,
- stretchWidth = true,
- richText = true,
- wordWrap = true,
- fontSize = 12,
- fixedHeight = 30f,
- fontStyle = FontStyle.Bold,
- padding = new RectOffset()
- {
- left = 14,
- right = 14,
- top = 8,
- bottom = 8
- }
- };
- }
- return _Tab;
- }
- }
- #endregion //Stylies
- }//Window Class
- }
|