static void Update() { EditorApplication.update -= Update; if (!EditorApplication.isPlayingOrWillChangePlaymode) { Preferences.ShowOption show = Preferences.ShowOption.Never; if (!EditorPrefs.HasKey(Preferences.PrefStartUp)) { show = Preferences.ShowOption.Always; EditorPrefs.SetInt(Preferences.PrefStartUp, 0); } else { if (Time.realtimeSinceStartup < 10) { show = (Preferences.ShowOption)EditorPrefs.GetInt(Preferences.PrefStartUp, 0); // check version here if (show == Preferences.ShowOption.OnNewVersion) { ASEStartScreen.StartBackgroundTask(StartRequest(ASEStartScreen.ChangelogURL, () => { var changeLog = ChangeLogInfo.CreateFromJSON(www.downloadHandler.text); if (changeLog != null) { if (changeLog.Version > VersionInfo.FullNumber) { ASEStartScreen.Init(); } } })); } } } if (show == Preferences.ShowOption.Always) { ASEStartScreen.Init(); } } }
static void Update() { EditorApplication.update -= Update; if (!EditorApplication.isPlayingOrWillChangePlaymode) { bool show = false; if (!EditorPrefs.HasKey("ASELastSession")) { show = true; EditorPrefs.SetBool("ASELastSession", true); } else { if (Time.realtimeSinceStartup < 10) { show = EditorPrefs.GetBool("ASELastSession", true); // check version here if (!show) { ASEStartScreen.StartBackgroundTask(StartRequest(ASEStartScreen.ChangelogURL, () => { var changeLog = ChangeLogInfo.CreateFromJSON(www.downloadHandler.text); if (changeLog != null) { if (changeLog.Version > VersionInfo.FullNumber) { ASEStartScreen.Init(); } } })); } } } if (show) { ASEStartScreen.Init(); } } }
public void OnGUI() { if (!m_infoDownloaded) { m_infoDownloaded = true; StartBackgroundTask(StartRequest(ChangelogURL, () => { var temp = ChangeLogInfo.CreateFromJSON(www.downloadHandler.text); if (temp != null && temp.Version >= m_changeLog.Version) { m_changeLog = temp; } // improve this later int major = m_changeLog.Version / 10000; int minor = (m_changeLog.Version / 1000) - major * 10; int release = (m_changeLog.Version / 100) - major * 100 - minor * 10; int revision = ((m_changeLog.Version / 10) - major * 1000 - minor * 100 - release * 10) + (m_changeLog.Version - major * 10000 - minor * 1000 - release * 100); m_newVersion = major + "." + minor + "." + release + "r" + revision; Repaint(); })); } if (m_buttonStyle == null) { m_buttonStyle = new GUIStyle(GUI.skin.button); m_buttonStyle.alignment = TextAnchor.MiddleLeft; } if (m_buttonLeftStyle == null) { m_buttonLeftStyle = new GUIStyle("ButtonLeft"); m_buttonLeftStyle.alignment = TextAnchor.MiddleLeft; m_buttonLeftStyle.margin = m_buttonStyle.margin; m_buttonLeftStyle.margin.right = 0; } if (m_buttonRightStyle == null) { m_buttonRightStyle = new GUIStyle("ButtonRight"); m_buttonRightStyle.alignment = TextAnchor.MiddleLeft; m_buttonRightStyle.margin = m_buttonStyle.margin; m_buttonRightStyle.margin.left = 0; } if (m_minibuttonStyle == null) { m_minibuttonStyle = new GUIStyle("MiniButton"); m_minibuttonStyle.alignment = TextAnchor.MiddleLeft; m_minibuttonStyle.margin = m_buttonStyle.margin; m_minibuttonStyle.margin.left = 20; m_minibuttonStyle.normal.textColor = m_buttonStyle.normal.textColor; m_minibuttonStyle.hover.textColor = m_buttonStyle.hover.textColor; } if (m_labelStyle == null) { m_labelStyle = new GUIStyle("BoldLabel"); m_labelStyle.margin = new RectOffset(4, 4, 4, 4); m_labelStyle.padding = new RectOffset(2, 2, 2, 2); m_labelStyle.fontSize = 13; } if (m_linkStyle == null) { var inv = AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDatabase.GUIDToAssetPath("1004d06b4b28f5943abdf2313a22790a")); // find a better solution for transparent buttons m_linkStyle = new GUIStyle(); m_linkStyle.normal.textColor = new Color(0.2980392f, 0.4901961f, 1f); m_linkStyle.hover.textColor = Color.white; m_linkStyle.active.textColor = Color.grey; m_linkStyle.margin.top = 3; m_linkStyle.margin.bottom = 2; m_linkStyle.hover.background = inv; m_linkStyle.active.background = inv; } EditorGUILayout.BeginHorizontal(GUIStyle.none, GUILayout.ExpandWidth(true)); { // left column EditorGUILayout.BeginVertical(GUILayout.Width(175)); { GUILayout.Label(SamplesTitle, m_labelStyle); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(HDRPbutton, m_buttonLeftStyle)) { ImportSample(HDRPbutton.text, HighDefinitionGUID); } if (GUILayout.Button(DownArrow, m_buttonRightStyle, GUILayout.Width(DownButtonSize), GUILayout.Height(DownButtonSize))) { m_showHDRP = !m_showHDRP; m_showLWRP = false; } EditorGUILayout.EndHorizontal(); if (m_showHDRP) { if (GUILayout.Button(HDRPOLDbutton, m_minibuttonStyle)) { ImportSample(HDRPOLDbutton.text, OLDHighDefinitionGUID); } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(URPbutton, m_buttonLeftStyle)) { ImportSample(URPbutton.text, UniversalGUID); } if (GUILayout.Button(DownArrow, m_buttonRightStyle, GUILayout.Width(DownButtonSize), GUILayout.Height(DownButtonSize))) { m_showLWRP = !m_showLWRP; m_showHDRP = false; } EditorGUILayout.EndHorizontal(); if (m_showLWRP) { EditorGUILayout.BeginVertical(); if (GUILayout.Button(LWRPbutton, m_minibuttonStyle)) { ImportSample(LWRPbutton.text, LightWeightGUID); } if (GUILayout.Button(LWRPOLDbutton, m_minibuttonStyle)) { ImportSample(LWRPOLDbutton.text, OLDLightWeightGUID); } EditorGUILayout.EndVertical(); } if (GUILayout.Button(BuiltInbutton, m_buttonStyle)) { ImportSample(BuiltInbutton.text, BuiltInGUID); } GUILayout.Space(10); GUILayout.Label(ResourcesTitle, m_labelStyle); if (GUILayout.Button(Manualbutton, m_buttonStyle)) { Application.OpenURL(ManualURL); } if (GUILayout.Button(Basicbutton, m_buttonStyle)) { Application.OpenURL(BasicURL); } if (GUILayout.Button(Beginnerbutton, m_buttonStyle)) { Application.OpenURL(BeginnerURL); } if (GUILayout.Button(Nodesbutton, m_buttonStyle)) { Application.OpenURL(NodesURL); } if (GUILayout.Button(SRPusebutton, m_buttonStyle)) { Application.OpenURL(SRPURL); } if (GUILayout.Button(Functionsbutton, m_buttonStyle)) { Application.OpenURL(FunctionsURL); } if (GUILayout.Button(Templatesbutton, m_buttonStyle)) { Application.OpenURL(TemplatesURL); } if (GUILayout.Button(APIbutton, m_buttonStyle)) { Application.OpenURL(APIURL); } } EditorGUILayout.EndVertical(); // right column EditorGUILayout.BeginVertical(GUILayout.Width(650 - 175 - 9), GUILayout.ExpandHeight(true)); { GUILayout.Label(CommunityTitle, m_labelStyle); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); { if (GUILayout.Button(DiscordButton, GUILayout.ExpandWidth(true))) { Application.OpenURL(DiscordURL); } if (GUILayout.Button(ForumButton, GUILayout.ExpandWidth(true))) { Application.OpenURL(ForumURL); } } EditorGUILayout.EndHorizontal(); GUILayout.Label(UpdateTitle, m_labelStyle); m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition, "ProgressBarBack", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUILayout.Label(m_changeLog.LastUpdate, "WordWrappedMiniLabel", GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); { EditorGUILayout.BeginVertical(); GUILayout.Label(ASETitle, m_labelStyle); GUILayout.Label("Installed Version: " + VersionInfo.StaticToString()); if (m_changeLog.Version > VersionInfo.FullNumber) { var cache = GUI.color; GUI.color = Color.red; GUILayout.Label("New version available: " + m_newVersion, "BoldLabel"); GUI.color = cache; } else { var cache = GUI.color; GUI.color = Color.green; GUILayout.Label("You are using the latest version", "BoldLabel"); GUI.color = cache; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Download links:"); if (GUILayout.Button("Amplify", m_linkStyle)) { Application.OpenURL(SiteURL); } GUILayout.Label("-"); if (GUILayout.Button("Asset Store", m_linkStyle)) { Application.OpenURL(StoreURL); } EditorGUILayout.EndHorizontal(); GUILayout.Space(7); EditorGUILayout.EndVertical(); GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical(); GUILayout.Space(7); GUILayout.Label(ASEIcon); EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal("ProjectBrowserBottomBarBg", GUILayout.ExpandWidth(true), GUILayout.Height(22)); { GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); var cache = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; m_startup = (Preferences.ShowOption)EditorGUILayout.EnumPopup("Show At Startup", m_startup, GUILayout.Width(220)); EditorGUIUtility.labelWidth = cache; if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(Preferences.PrefStartUp, (int)m_startup); } } EditorGUILayout.EndHorizontal(); // Find a better way to update link buttons without repainting the window Repaint(); }
private void OnEnable() { rt = new RenderTexture(16, 16, 0); rt.Create(); m_startup = (Preferences.ShowOption)EditorPrefs.GetInt(Preferences.PrefStartUp, 0); if (textIcon == null) { Texture icon = EditorGUIUtility.IconContent("TextAsset Icon").image; var cache = RenderTexture.active; RenderTexture.active = rt; Graphics.Blit(icon, rt); RenderTexture.active = cache; textIcon = rt; Manualbutton = new GUIContent(" Manual", textIcon); Basicbutton = new GUIContent(" Basic use tutorials", textIcon); Beginnerbutton = new GUIContent(" Beginner Series", textIcon); Nodesbutton = new GUIContent(" Node List", textIcon); SRPusebutton = new GUIContent(" SRP HD/URP/LW use", textIcon); Functionsbutton = new GUIContent(" Shader Functions", textIcon); Templatesbutton = new GUIContent(" Shader Templates", textIcon); APIbutton = new GUIContent(" Node API", textIcon); } if (packageIcon == null) { packageIcon = EditorGUIUtility.IconContent("BuildSettings.Editor.Small").image; HDRPbutton = new GUIContent(" HDRP Samples", packageIcon); HDRPOLDbutton = new GUIContent(" HDRP Samples 6.X.X", packageIcon); URPbutton = new GUIContent(" URP Samples", packageIcon); LWRPbutton = new GUIContent(" LWRP Samples 6.X.X", packageIcon); LWRPOLDbutton = new GUIContent(" LWRP Samples 3.X.X", packageIcon); BuiltInbutton = new GUIContent(" Built-In Samples", packageIcon); } if (webIcon == null) { webIcon = EditorGUIUtility.IconContent("BuildSettings.Web.Small").image; DiscordButton = new GUIContent(" Discord", webIcon); ForumButton = new GUIContent(" Unity Forum", webIcon); } if (m_changeLog == null) { var changelog = AssetDatabase.LoadAssetAtPath <TextAsset>(AssetDatabase.GUIDToAssetPath(ChangeLogGUID)); string lastUpdate = string.Empty; if (changelog != null) { lastUpdate = changelog.text.Substring(0, changelog.text.IndexOf("\nv", 50)); // + "\n..."; lastUpdate = lastUpdate.Replace(" *", " \u25CB"); lastUpdate = lastUpdate.Replace("* ", "\u2022 "); } m_changeLog = new ChangeLogInfo(VersionInfo.FullNumber, lastUpdate); } if (ASEIcon == null) { ASEIcon = new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDatabase.GUIDToAssetPath(IconGUID))); } }