public void StoresChanged() { if (!autoBackgroundUpdate) { return; } lock (this) { m_Debounce.Execute(); } }
private static void OnMenuChanged() { debounce.Execute(); }
private void SetupUI() { var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>($"{Utils.packageFolderName}/Editor/StyleSheets/PerformanceTrackerWindow.uss"); rootVisualElement.styleSheets.Add(styleSheet); m_RefreshFromSearch = Delayer.Throttle(RefreshFromSearch); var toolbar = new UIElements.Toolbar(); toolbar.AddToClassList("perf-toolbar"); toolbar.style.height = PtStyles.itemHeight; var searchBox = new VisualElement(); searchBox.AddToClassList("perf-search-box"); AddSelectorLabel(toolbar, "Tracker"); m_SearchField = new UIElements.ToolbarSearchField(); m_SearchField.AddToClassList("perf-search-tracker"); m_SearchField.value = m_FilterText; m_SearchField.RegisterCallback <ChangeEvent <string> >((evt) => { m_RefreshFromSearch.Execute(evt.newValue); }); searchBox.Add(m_SearchField); toolbar.Add(searchBox); var resetAllCountersButton = new Button(ResetAllCounters); resetAllCountersButton.text = "Reset all counters"; resetAllCountersButton.AddToClassList("perf-tracker-toolbar-button"); toolbar.Add(resetAllCountersButton); AddSelectorLabel(toolbar, "Update Speed"); var choices = PtModel.RefreshRates.Select(r => r.label).ToList(); var updateSpeedSelector = new UIElements.PopupField <string>(choices, 0); updateSpeedSelector.value = PtModel.RefreshRates[m_UpdateSpeedIndex].label; updateSpeedSelector.AddToClassList("perf-update-speed-selector"); updateSpeedSelector.RegisterCallback <ChangeEvent <string> >((evt) => { m_UpdateSpeedIndex = Array.FindIndex(PtModel.RefreshRates, (r) => r.label == evt.newValue); ScheduleNextRefresh(); SendAnalytics(Analytics.WindowUsageType.ChangeMonitoringSpeed); }); toolbar.Add(updateSpeedSelector); AddSelectorLabel(toolbar, "Columns"); var columnsChoice = PtModel.ColumnDescriptors.Where(desc => desc.columnsSelectorMaskId > 0).Select(desc => desc.label).ToList(); var columnsSelector = new UIElements.MaskField(columnsChoice, m_ShownColumn); columnsSelector.RegisterCallback <ChangeEvent <int> >((evt) => { m_ShownColumn = evt.newValue; CreateHeaders(); RefreshTrackers(); SendAnalytics(Analytics.WindowUsageType.ChangeColumnLayout); }); columnsSelector.AddToClassList("perf-columns-selector"); toolbar.Add(columnsSelector); AddSelectorLabel(toolbar, "Sort By"); m_SortBySelector = new UIElements.EnumField(ColumnId.Name); m_SortBySelector.value = m_SortBy; m_SortBySelector.AddToClassList("perf-sort-by-selector"); m_SortBySelector.RegisterCallback <ChangeEvent <Enum> >((evt) => { ChangeSortOrder((ColumnId)evt.newValue); SendAnalytics(Analytics.WindowUsageType.ChangeSortBy); }); toolbar.Add(m_SortBySelector); var settingsBtn = new Button(() => { SettingsService.OpenUserPreferences(PerformanceTrackerSettings.settingsKey); SendAnalytics(Analytics.WindowUsageType.OpenPreferences); }); settingsBtn.style.backgroundImage = Icons.settings; settingsBtn.style.width = PtStyles.itemHeight - 3; settingsBtn.style.height = PtStyles.itemHeight - 3; toolbar.Add(settingsBtn); rootVisualElement.Add(toolbar); // Set List View Header: m_HeaderRow = new VisualElement(); m_HeaderRow.AddToClassList("perf-header-row-container"); m_HeaderRow.style.flexDirection = FlexDirection.Row; rootVisualElement.Add(m_HeaderRow); CreateHeaders(); m_PinnedTrackersView = new ListView(m_PinnedTrackers, PtStyles.itemHeight, MakeItem, BindPinnedItem); m_PinnedTrackersView.name = k_PinnedTrackerList; m_PinnedTrackersView.AddToClassList("perf-tracker-list"); m_PinnedTrackersView.selectionType = SelectionType.Multiple; m_PinnedTrackersView.style.flexGrow = 0; m_PinnedTrackersView.Q <VisualElement>(null, "unity-scroll-view__content-viewport").RegisterCallback <GeometryChangedEvent>(SyncHeaderAndListsGeometry); rootVisualElement.Add(m_PinnedTrackersView); m_TrackersView = new ListView(m_FilteredTrackers, PtStyles.itemHeight, MakeItem, BindUnpinnedItem); m_TrackersView.name = k_TrackerList; m_TrackersView.AddToClassList("perf-tracker-list"); m_TrackersView.selectionType = SelectionType.Multiple; m_TrackersView.style.flexGrow = 1.0f; m_TrackersView.Q <VisualElement>(null, "unity-scroll-view__content-viewport").RegisterCallback <GeometryChangedEvent>(SyncHeaderAndListsGeometry); rootVisualElement.Add(m_TrackersView); m_NeedsUpdate = true; ScheduleNextRefresh(); UpdateTrackers(); }