Пример #1
0
        private void OnGUI()
        {
            // Ensure styles are loaded.
            InitializeStyles();

            // Ensure preferences are loaded.
            if (shouldReloadPreferences)
            {
                selectionHistory.HistorySize = EditorPrefs.GetInt(SelectionHistoryWindow.HistorySizePrefKey, 10);
                allowDuplicatedEntries       = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryAllowDuplicatedEntriesPrefKey, false);
                automaticRemoveDeleted       = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryAutomaticRemoveDeletedPrefKey, true);
                showHierarchyViewObjects     = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryShowHierarchyObjectsPrefKey, true);
                showProjectViewObjects       = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryShowProjectViewObjectsPrefKey, true);
                favoritesEnabled             = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryFavoritesPrefKey, true);
                favoritesFirst          = EditorPrefs.GetBool(SelectionHistoryWindow.HistoryFavoritesFirstPrefKey, false);
                shouldReloadPreferences = false;
            }

            // Clear any items that should not be shown.
            if (automaticRemoveDeleted)
            {
                selectionHistory.RemovedDestroyed();
            }
            if (!allowDuplicatedEntries)
            {
                selectionHistory.RemoveDuplicated();
            }

            // Draw the elements in a scroll view.
            historyScrollPosition = EditorGUILayout.BeginScrollView(historyScrollPosition, GUILayout.ExpandHeight(true));
            if (favoritesFirst)
            {
                DrawFavorites();
                DrawHistory();
            }
            else
            {
                DrawHistory();
                DrawFavorites();
            }
            EditorGUILayout.EndScrollView();

            // Draw a sidebar on the left to match the hierarchy view visually.
            if (favoritesEnabled)
            {
                var sidebar = GUILayoutUtility.GetLastRect();
                sidebar.width = LINE_HEIGHT;
                DrawColoredBox(sidebar, Color.black * 0.176f);
            }

            DrawButtorBar();
        }