private void OnGUI() { EditorGUILayout.BeginVertical(BOX); GUILayout.Space(1); #region Help Button EditorGUILayout.BeginHorizontal(); var iconStyle = new GUIStyle(GUIStyle.none) { padding = new RectOffset(-1, 0, -2, 0) }; GUILayout.Label(ToolIconSmall, iconStyle, GUILayout.Height(17), GUILayout.Width(17)); EditorGUILayout.Space(); if (_helpBttn == null) { _helpBttn = EditorGUIUtility.Load("_Help") as Texture2D; } var helpStyle = new GUIStyle(GUIStyle.none) { fontStyle = FontStyle.Bold }; var helpContent = new GUIContent(string.Empty, _helpBttn, "Opens Recent Scenes Manager Info"); if (GUILayout.Button(helpContent, helpStyle, GUILayout.Width(15))) { if (_infoWindow == null) { _infoWindow = InfoWindow.InfoInit(); } } GUILayout.Space(1); EditorGUILayout.EndHorizontal(); #endregion GUILayout.Space(3); var content = new GUIContent("Max Tracked Scenes"); var wasTrack = RecentSceneManager.keepTrackOfRecentScenes; RecentSceneManager.keepTrackOfRecentScenes = EditorGUILayout.IntSlider(content, RecentSceneManager.keepTrackOfRecentScenes, 2, 20); if (wasTrack != RecentSceneManager.keepTrackOfRecentScenes) { InitializeSceneManager.SetEditorPrefInt(InitializeSceneManager.TRACKEDCOUNT, RecentSceneManager.keepTrackOfRecentScenes); while (RecentSceneManager.recentScenes.Count > RecentSceneManager.keepTrackOfRecentScenes) { var last = RecentSceneManager.recentScenes[RecentSceneManager.recentScenes.Count - 1]; if (RecentSceneManager.pathAndScene.ContainsKey(last)) { var scene = RecentSceneManager.pathAndScene[last]; RecentSceneManager.pathAndScene.Remove(last); scene.ClearImage(); } InitializeSceneManager.SetEditorPrefString( $"{Application.productName}{RECENTSCENES}{RecentSceneManager.recentScenes.Count - 1}", string.Empty); RecentSceneManager.recentScenes.Remove(last); } _window.OnGUI(); } EditorGUILayout.Space(); var trackScenes = RecentSceneManager.trackScenePreview; RecentSceneManager.trackScenePreview = EditorGUILayout.Toggle("Track Scene Previews", RecentSceneManager.trackScenePreview); if (trackScenes != RecentSceneManager.trackScenePreview) { InitializeSceneManager.SetEditorPrefBool(InitializeSceneManager.TRACKSCENEPREVIEW, RecentSceneManager.trackScenePreview); } var trackEdited = RecentSceneManager.trackEditedBy; RecentSceneManager.trackEditedBy = EditorGUILayout.Toggle("Track Edited By", RecentSceneManager.trackEditedBy); if (trackEdited != RecentSceneManager.trackEditedBy) { InitializeSceneManager.SetEditorPrefBool(InitializeSceneManager.TRACKEDITEDBY, RecentSceneManager.trackEditedBy); } EditorGUILayout.Space(); var close = RecentSceneManager.closeWindowOnLoad; RecentSceneManager.closeWindowOnLoad = EditorGUILayout.ToggleLeft("Close Window On Load", RecentSceneManager.closeWindowOnLoad); if (close != RecentSceneManager.closeWindowOnLoad) { InitializeSceneManager.SetEditorPrefBool(InitializeSceneManager.CLOSEWINDOWONLOAD, RecentSceneManager.closeWindowOnLoad); } EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(RecentSceneManager.recentScenes.Count == 0); if (GUILayout.Button(CLEARRECENT)) { for (var j = 0; j < RecentSceneManager.recentScenes.Count; j++) { RecentSceneManager.recentScenes[j] = null; InitializeSceneManager.RemoveKey(Application.productName + RECENTSCENES + j); } } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); }
private void OnGUI() { if (_window == null) { _window = this; _window.titleContent.image = ToolIcon; } EditorGUILayout.BeginVertical(BOX); GUILayout.Space(2); #region Help Button EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (_helpBttn == null) { _helpBttn = EditorGUIUtility.Load(HELPICON) as Texture2D; } var helpStyle = new GUIStyle(GUIStyle.none) { fontStyle = FontStyle.Bold }; var helpContent = new GUIContent(string.Empty, _helpBttn, HELPTOOLTIP); if (GUILayout.Button(helpContent, helpStyle, GUILayout.Width(15))) { if (_infoWindow == null) { _infoWindow = InfoWindow.InfoInit(); } } GUILayout.Space(3); EditorGUILayout.EndHorizontal(); #endregion GUILayout.Space(1); #region Fav or Recent Tab EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); var tabSkin = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleCenter, fontSize = 12, fontStyle = FontStyle.Bold }; var recentBttn = new GUIContent(RECENT, RECENTBUTTONTOOLTIP); var favoriteBttn = new GUIContent(FAVORITES, FAVORITESBUTTONTOOLTIP); RecentSceneManager.recentOrFav = GUILayout.SelectionGrid(RecentSceneManager.recentOrFav, new[] { recentBttn, favoriteBttn }, 2, tabSkin, GUILayout.MaxWidth(200)); EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); #endregion GUILayout.Label("", GUI.skin.horizontalSlider); _scrollPos = GUILayout.BeginScrollView(_scrollPos); if (RecentSceneManager.recentOrFav == 0) { var labelWidth = 0f; foreach (var scene in RecentSceneManager.recentScenes) { var textDimensions = GUI.skin.label.CalcSize(new GUIContent(scene)); if (textDimensions.x > labelWidth) { labelWidth = textDimensions.x; } } for (var i = 0; i < RecentSceneManager.recentScenes.Count; i++) { i = DisplayObject(i, RecentSceneManager.recentScenes); } if (RecentSceneManager.recentScenes.Count > 0) { var spaceSize = RecentSceneManager.keepTrackOfRecentScenes + 1 - RecentSceneManager.recentScenes.Count; spaceSize *= 28; GUILayout.Space(pixels: spaceSize); EditorGUILayout.EndScrollView(); if (GUILayout.Button(CLEARRECENT)) { for (var j = 0; j < RecentSceneManager.recentScenes.Count; j++) { RecentSceneManager.recentScenes[j] = null; InitializeSceneManager.RemoveKey(Application.productName + RECENTSCENES + j); } } } else { EditorGUILayout.EndScrollView(); GUILayout.Space(20); var centerBoldLabel = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold }; GUILayout.Label(NORECENT, centerBoldLabel); GUILayout.Space(130); if (GUILayout.Button(RecentSceneManager.CLOSE)) { _window.Close(); } } } else { var labelWidth = 0f; foreach (var scene in FavoriteScenesManager.favoritedScenes) { var textDimensions = GUI.skin.label.CalcSize(new GUIContent(scene)); if (textDimensions.x > labelWidth) { labelWidth = textDimensions.x; } } for (var i = 0; i < FavoriteScenesManager.favoritedScenes.Count; i++) { i = DisplayObject(i, FavoriteScenesManager.favoritedScenes); } if (FavoriteScenesManager.favoritedScenes.Count > 0) { var spaceSize = RecentSceneManager.keepTrackOfRecentScenes + 1 - RecentSceneManager.recentScenes.Count; spaceSize *= 28; GUILayout.Space(pixels: spaceSize); EditorGUILayout.EndScrollView(); var clearFavBttn = new GUIContent(CLEARFAVORITES, CLEARFAVTOOLTIP); if (GUILayout.Button(clearFavBttn)) { if (EditorUtility.DisplayDialog(CLEARFAVCONFIRM, CLEARFAVMSG, RecentSceneManager.YES, RecentSceneManager.NO)) { for (var j = 0; j < FavoriteScenesManager.favoritedScenes.Count; j++) { FavoriteScenesManager.favoritedScenes[j] = null; InitializeSceneManager.RemoveKey(Application.productName + FAVORITESCENES + j); } FavoriteScenesManager.favoritedScenes.Clear(); } } } else { EditorGUILayout.EndScrollView(); GUILayout.Space(20); var centerBoldLabel = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold }; GUILayout.Label(NOFAVORITES, centerBoldLabel); GUILayout.Space(130); if (GUILayout.Button(RecentSceneManager.CLOSE)) { _window.Close(); } } } EditorGUILayout.EndVertical(); }