internal static void RemoveFromFavorites(string path)
        {
            var index = favoritedScenes.IndexOf(path);

            if (index < 0)
            {
                return;
            }

            favoritedScenes.Remove(path);
            for (var i = index; i < favoritedScenes.Count; i++)
            {
                var saveName = $"{Application.productName}{FAVORITESCENES}{i}";
                InitializeSceneManager.SetEditorPrefString(saveName, favoritedScenes[i]);
            }

            InitializeSceneManager.SetEditorPrefInt($"{Application.productName}{FAVORITEDSCENESCOUNT}",
                                                    favoritedScenes.Count);
        }
        internal static void AddToFavorites(string path)
        {
            if (favoritedScenes.Contains(path))
            {
                return;
            }

            favoritedScenes.Add(path);
            var saveName = $"{Application.productName}{FAVORITESCENES}{favoritedScenes.Count - 1}";

            InitializeSceneManager.SetEditorPrefString(saveName, path);
            InitializeSceneManager.SetEditorPrefInt($"{Application.productName}{FAVORITEDSCENESCOUNT}",
                                                    favoritedScenes.Count);
            if (RecentSceneManager.pathAndScene.ContainsKey(path))
            {
                var sceneJson = EditorJsonUtility.ToJson(RecentSceneManager.pathAndScene[path]);
                if (!string.IsNullOrWhiteSpace(sceneJson))
                {
                    InitializeSceneManager.SetEditorPrefString(
                        $"{Application.productName}{ACTUALFAVORITEDSCENES}{favoritedScenes.Count - 1}", sceneJson);
                }
            }
            ShowRecentScenes.Window.RefreshGUI();
        }
Ejemplo n.º 3
0
            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();
            }