Exemple #1
0
        private void DrawButtorBar()
        {
            GUILayout.BeginHorizontal();
            {
                var backContent = new GUIContent(EditorGUIUtility.IconContent(iconPath + "back").image, "Back");
                if (GUILayout.Button(backContent, lineHeight))
                {
                    PreviousSelection();
                }

                var forwardContent = new GUIContent(EditorGUIUtility.IconContent(iconPath + "forward").image, "Forward");
                if (GUILayout.Button(forwardContent, lineHeight))
                {
                    NextSelection();
                }

                if (GUILayout.Button("Clear", GUILayout.Width(70), lineHeight))
                {
                    selectionHistory.Clear();
                    Repaint();
                }
            }
            GUILayout.EndHorizontal();
        }
        void OnGUI()
        {
            if (shouldReloadPreferences)
            {
                selectionHistory.HistorySize = EditorPrefs.GetInt(SelectionHistoryWindow.HistorySizePrefKey, 10);
                automaticRemoveDeleted       = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryAutomaticRemoveDeletedPrefKey, true);
                allowDuplicatedEntries       = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryAllowDuplicatedEntriesPrefKey, false);

                showHierarchyViewObjects = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryShowHierarchyObjectsPrefKey, true);
                showProjectViewObjects   = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryShowProjectViewObjectsPrefKey, true);

                shouldReloadPreferences = false;
            }

            if (automaticRemoveDeleted)
            {
                selectionHistory.ClearDeleted();
            }

            if (!allowDuplicatedEntries)
            {
                selectionHistory.RemoveDuplicated();
            }

            var favoritesEnabled = EditorPrefs.GetBool(HistoryFavoritesPrefKey, true);

            if (favoritesEnabled && selectionHistory.Favorites.Count > 0)
            {
                _favoritesScrollPosition = EditorGUILayout.BeginScrollView(_favoritesScrollPosition);
                DrawFavorites();
                EditorGUILayout.EndScrollView();
                EditorGUILayout.Separator();
            }

            bool changedBefore = GUI.changed;

            _historyScrollPosition = EditorGUILayout.BeginScrollView(_historyScrollPosition);

            bool changedAfter = GUI.changed;

            if (!changedBefore && changedAfter)
            {
                Debug.Log("changed");
            }

            DrawHistory();

            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Clear"))
            {
                selectionHistory.Clear();
                Repaint();
            }

            if (!automaticRemoveDeleted)
            {
                if (GUILayout.Button("Remove Deleted"))
                {
                    selectionHistory.ClearDeleted();
                    Repaint();
                }
            }

            if (allowDuplicatedEntries)
            {
                if (GUILayout.Button("Remove Duplciated"))
                {
                    selectionHistory.RemoveDuplicated();
                    Repaint();
                }
            }

            DrawSettingsButton();
        }