void SBlueprintProfilerView::Construct(const FArguments& InArgs) { CurrentViewType = InArgs._ProfileViewType; BlueprintEditor = InArgs._AssetEditor; // Register for Profiler toggle events FBlueprintCoreDelegates::OnToggleScriptProfiler.AddSP(this, &SBlueprintProfilerView::OnToggleProfiler); // Initialise the number format. FNumberFormattingOptions StatisticNumberFormat; StatisticNumberFormat.MinimumFractionalDigits = 4; StatisticNumberFormat.MaximumFractionalDigits = 4; StatisticNumberFormat.UseGrouping = false; FScriptPerfData::SetNumberFormattingForStats(StatisticNumberFormat); // Create the display text for the user if (GetDefault<UEditorExperimentalSettings>()->bBlueprintPerformanceAnalysisTools) { IBlueprintProfilerInterface* ProfilerInterface = FModuleManager::GetModulePtr<IBlueprintProfilerInterface>("BlueprintProfiler"); const bool bProfilerEnabled = ProfilerInterface && ProfilerInterface->IsProfilerEnabled(); StatusText = bProfilerEnabled ? LOCTEXT("ProfilerNoDataText", "The Blueprint Profiler is active but does not currently have any data to display") : LOCTEXT("ProfilerInactiveText", "The Blueprint Profiler is currently Inactive"); } else { StatusText = LOCTEXT("DisabledProfilerText", "The Blueprint Profiler is experimental and is currently not enabled in the editor preferences"); } // Create the profiler view widgets UpdateActiveProfilerWidget(); }
void SBlueprintProfilerView::UpdateStatusMessage() { if (GetDefault<UEditorExperimentalSettings>()->bBlueprintPerformanceAnalysisTools) { IBlueprintProfilerInterface* ProfilerInterface = FModuleManager::GetModulePtr<IBlueprintProfilerInterface>("BlueprintProfiler"); if (ProfilerInterface && ProfilerInterface->IsProfilerEnabled()) { UBlueprint* CurrentBP = BlueprintEditor.IsValid() ? BlueprintEditor.Pin()->GetBlueprintObj() : nullptr; if (CurrentBP && CurrentBP->GeneratedClass->HasInstrumentation()) { StatusText = LOCTEXT("ProfilerNoDataText", "The Blueprint Profiler is active but does not currently have any data to display"); } else { StatusText = LOCTEXT("ProfilerNoInstrumentationText", "The Blueprint Profiler is active but the current blueprint does not have any instrumentation"); } } else { StatusText = LOCTEXT("ProfilerInactiveText", "The Blueprint Profiler is currently Inactive"); } } else { StatusText = LOCTEXT("DisabledProfilerText", "The Blueprint Profiler is experimental and is currently not enabled in the editor preferences"); } }
TSharedRef<SWidget> SBlueprintProfilerView::CreateActiveStatisticWidget() { // Get profiler status EBlueprintPerfViewType::Type NewViewType = EBlueprintPerfViewType::None; IBlueprintProfilerInterface* ProfilerInterface = FModuleManager::GetModulePtr<IBlueprintProfilerInterface>("BlueprintProfiler"); if (ProfilerInterface && ProfilerInterface->IsProfilerEnabled()) { NewViewType = CurrentViewType; } switch(NewViewType) { case EBlueprintPerfViewType::Overview: { return SNew(SProfilerOverview) .AssetEditor(BlueprintEditor); } case EBlueprintPerfViewType::ExecutionGraph: { return SNew(SGraphExecutionStatDisplay) .AssetEditor(BlueprintEditor); } case EBlueprintPerfViewType::LeastPerformant: { return SNew(SLeastPerformantDisplay) .AssetEditor(BlueprintEditor); } default: { // Default place holder return SNew(SVerticalBox) +SVerticalBox::Slot() .HAlign(HAlign_Center) .VAlign(VAlign_Center) .Padding(0) [ SNew(SHorizontalBox) +SHorizontalBox::Slot() [ SNew(SBorder) .Padding(0) .BorderImage(FEditorStyle::GetBrush("NoBorder")) .HAlign(HAlign_Center) .VAlign(VAlign_Center) [ SNew(STextBlock) .Text(this, &SBlueprintProfilerView::GetProfilerStatusText) ] ] ]; } } }
void SBlueprintProfilerView::Construct(const FArguments& InArgs) { BlueprintEditor = InArgs._AssetEditor; // Register for Profiler toggle events FBlueprintCoreDelegates::OnToggleScriptProfiler.AddSP(this, &SBlueprintProfilerView::OnToggleProfiler); // Remove delegate for graph structural changes IBlueprintProfilerInterface& ProfilerModule = FModuleManager::LoadModuleChecked<IBlueprintProfilerInterface>("BlueprintProfiler"); ProfilerModule.GetGraphLayoutChangedDelegate().AddSP(this, &SBlueprintProfilerView::OnGraphLayoutChanged); // Initialise the number format. FNumberFormattingOptions StatisticNumberFormat; StatisticNumberFormat.MinimumFractionalDigits = 4; StatisticNumberFormat.MaximumFractionalDigits = 4; StatisticNumberFormat.UseGrouping = false; FNumberFormattingOptions TimeNumberFormat; TimeNumberFormat.MinimumFractionalDigits = 1; TimeNumberFormat.MaximumFractionalDigits = 1; TimeNumberFormat.UseGrouping = false; FScriptPerfData::SetNumberFormattingForStats(StatisticNumberFormat, TimeNumberFormat); // Create the display text for the user if (GetDefault<UEditorExperimentalSettings>()->bBlueprintPerformanceAnalysisTools) { IBlueprintProfilerInterface* ProfilerInterface = FModuleManager::GetModulePtr<IBlueprintProfilerInterface>("BlueprintProfiler"); const bool bProfilerEnabled = ProfilerInterface && ProfilerInterface->IsProfilerEnabled(); StatusText = bProfilerEnabled ? LOCTEXT("ProfilerNoDataText", "The Blueprint Profiler is active but does not currently have any data to display") : LOCTEXT("ProfilerInactiveText", "The Blueprint Profiler is currently Inactive"); } else { StatusText = LOCTEXT("DisabledProfilerText", "The Blueprint Profiler is experimental and is currently not enabled in the editor preferences"); } // Create Display Options if (!DisplayOptions.IsValid()) { DisplayOptions = MakeShareable(new FBlueprintProfilerStatOptions); } // Create the toolbar SAssignNew(ProfilerToolbar, SBlueprintProfilerToolbar) .ProfileViewType(InArgs._ProfileViewType) .DisplayOptions(DisplayOptions) .OnViewChanged(this, &SBlueprintProfilerView::OnViewChanged); // Create the profiler view widgets UpdateActiveProfilerWidget(); }