2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Modules/ModuleManager.h"
|
|
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
#include "Framework/Docking/TabManager.h"
|
|
|
|
|
#include "IBlutilityModule.h"
|
2019-02-13 17:03:46 -05:00
|
|
|
#include "EditorUtilityWidget.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "EditorUtilityBlueprint.h"
|
2019-02-13 17:03:46 -05:00
|
|
|
#include "GlobalEditorUtilityBase.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "AssetToolsModule.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "PropertyEditorModule.h"
|
|
|
|
|
#include "AssetTypeActions_EditorUtilityBlueprint.h"
|
|
|
|
|
#include "WorkspaceMenuStructure.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
#include "WorkspaceMenuStructureModule.h"
|
|
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Widgets/Docking/SDockTab.h"
|
2018-02-22 11:25:06 -05:00
|
|
|
#include "BlutilityContentBrowserExtensions.h"
|
|
|
|
|
#include "BlutilityLevelEditorExtensions.h"
|
2018-09-05 17:18:42 -04:00
|
|
|
#include "AssetTypeActions_EditorUtilityWidgetBlueprint.h"
|
|
|
|
|
#include "KismetCompiler.h"
|
|
|
|
|
#include "EditorUtilityWidgetBlueprint.h"
|
|
|
|
|
#include "ComponentReregisterContext.h"
|
|
|
|
|
#include "KismetCompilerModule.h"
|
|
|
|
|
#include "WidgetBlueprintCompiler.h"
|
|
|
|
|
#include "UMGEditorModule.h"
|
2019-05-08 18:48:36 -04:00
|
|
|
#include "EditorUtilitySubsystem.h"
|
2018-09-05 17:18:42 -04:00
|
|
|
#include "LevelEditor.h"
|
|
|
|
|
#include "Editor.h"
|
|
|
|
|
#include "UnrealEdMisc.h"
|
2019-02-13 17:03:46 -05:00
|
|
|
#include "EditorSupportDelegates.h"
|
|
|
|
|
#include "UObject/PurgingReferenceCollector.h"
|
2022-05-02 18:06:48 -04:00
|
|
|
#include "AssetRegistry/AssetRegistryModule.h"
|
2019-05-08 13:56:41 -04:00
|
|
|
#include "EditorUtilityCommon.h"
|
2020-08-11 01:36:57 -04:00
|
|
|
#include "EditorUtilityToolMenu.h"
|
2018-09-05 17:18:42 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "AssetTypeActions"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-05-08 13:56:41 -04:00
|
|
|
DEFINE_LOG_CATEGORY(LogEditorUtilityBlueprint);
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
namespace BlutilityModule
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// FBlutilityModule
|
|
|
|
|
|
|
|
|
|
// Blutility module implementation (private)
|
2018-09-05 17:18:42 -04:00
|
|
|
class FBlutilityModule : public IBlutilityModule, public FGCObject
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2019-06-10 18:07:11 -04:00
|
|
|
/** Asset type actions for editor utility assets. Cached here so that we can unregister it during shutdown. */
|
2014-03-14 14:13:41 -04:00
|
|
|
TSharedPtr<FAssetTypeActions_EditorUtilityBlueprint> EditorBlueprintAssetTypeActions;
|
2018-09-05 17:18:42 -04:00
|
|
|
TSharedPtr<FAssetTypeActions_EditorUtilityWidgetBlueprint> EditorWidgetBlueprintAssetTypeActions;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
public:
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void StartupModule() override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
// Register the asset type
|
2018-09-05 17:18:42 -04:00
|
|
|
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
|
|
|
|
EditorUtilityAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("EditorUtilities")), LOCTEXT("EditorUtilitiesAssetCategory", "Editor Utilities"));
|
2014-03-14 14:13:41 -04:00
|
|
|
EditorBlueprintAssetTypeActions = MakeShareable(new FAssetTypeActions_EditorUtilityBlueprint);
|
2018-09-05 17:18:42 -04:00
|
|
|
AssetTools.RegisterAssetTypeActions(EditorBlueprintAssetTypeActions.ToSharedRef());
|
|
|
|
|
EditorWidgetBlueprintAssetTypeActions = MakeShareable(new FAssetTypeActions_EditorUtilityWidgetBlueprint);
|
|
|
|
|
AssetTools.RegisterAssetTypeActions(EditorWidgetBlueprintAssetTypeActions.ToSharedRef());
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2018-09-05 17:18:42 -04:00
|
|
|
FKismetCompilerContext::RegisterCompilerForBP(UEditorUtilityWidgetBlueprint::StaticClass(), &UWidgetBlueprint::GetCompilerForWidgetBP);
|
|
|
|
|
|
|
|
|
|
// Register widget blueprint compiler we do this no matter what.
|
|
|
|
|
IUMGEditorModule& UMGEditorModule = FModuleManager::LoadModuleChecked<IUMGEditorModule>("UMGEditor");
|
|
|
|
|
IKismetCompilerInterface& KismetCompilerModule = FModuleManager::LoadModuleChecked<IKismetCompilerInterface>("KismetCompiler");
|
|
|
|
|
KismetCompilerModule.GetCompilers().Add(UMGEditorModule.GetRegisteredCompiler());
|
2018-02-22 11:25:06 -05:00
|
|
|
|
|
|
|
|
FBlutilityContentBrowserExtensions::InstallHooks();
|
|
|
|
|
FBlutilityLevelEditorExtensions::InstallHooks();
|
2018-09-05 17:18:42 -04:00
|
|
|
|
|
|
|
|
ScriptedEditorWidgetsGroup = WorkspaceMenu::GetMenuStructure().GetToolsCategory()->AddGroup(
|
|
|
|
|
LOCTEXT("WorkspaceMenu_EditorUtilityWidgetsGroup", "Editor Utility Widgets"),
|
|
|
|
|
LOCTEXT("ScriptedEditorWidgetsGroupTooltipText", "Custom editor UI created with Blueprints or Python."),
|
2022-05-09 13:12:28 -04:00
|
|
|
FSlateIcon(FAppStyle::GetAppStyleSetName(), "WorkspaceMenu.AdditionalUI"),
|
2018-09-05 17:18:42 -04:00
|
|
|
true);
|
|
|
|
|
|
|
|
|
|
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
|
|
|
|
|
LevelEditorModule.OnTabManagerChanged().AddRaw(this, &FBlutilityModule::ReinitializeUIs);
|
|
|
|
|
LevelEditorModule.OnMapChanged().AddRaw(this, &FBlutilityModule::OnMapChanged);
|
2019-02-13 17:03:46 -05:00
|
|
|
FEditorSupportDelegates::PrepareToCleanseEditorObject.AddRaw(this, &FBlutilityModule::OnPrepareToCleanseEditorObject);
|
2019-02-27 10:40:48 -05:00
|
|
|
|
|
|
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
|
|
|
AssetRegistryModule.Get().OnAssetRemoved().AddRaw(this, &FBlutilityModule::HandleAssetRemoved);
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ReinitializeUIs()
|
|
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
|
2019-02-27 10:39:53 -05:00
|
|
|
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
|
|
|
|
|
TSharedPtr<FTabManager> LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager();
|
|
|
|
|
TArray<FSoftObjectPath> CorrectPaths;
|
2019-05-08 18:48:36 -04:00
|
|
|
for (const FSoftObjectPath& BlueprintPath : EditorUtilitySubsystem->LoadedUIs)
|
2019-02-27 10:39:53 -05:00
|
|
|
{
|
|
|
|
|
UObject* BlueprintObject = BlueprintPath.TryLoad();
|
2021-11-18 14:37:34 -05:00
|
|
|
if (BlueprintObject && IsValidChecked(BlueprintObject) && !BlueprintObject->IsUnreachable())
|
2019-02-27 10:39:53 -05:00
|
|
|
{
|
|
|
|
|
UEditorUtilityWidgetBlueprint* Blueprint = Cast<UEditorUtilityWidgetBlueprint>(BlueprintObject);
|
2019-05-08 13:56:41 -04:00
|
|
|
if (Blueprint)
|
2018-09-05 17:18:42 -04:00
|
|
|
{
|
2019-05-08 13:56:41 -04:00
|
|
|
if (Blueprint->GeneratedClass)
|
|
|
|
|
{
|
|
|
|
|
const UEditorUtilityWidget* CDO = Blueprint->GeneratedClass->GetDefaultObject<UEditorUtilityWidget>();
|
|
|
|
|
FName RegistrationName = FName(*(Blueprint->GetPathName() + LOCTEXT("ActiveTabSuffix", "_ActiveTab").ToString()));
|
|
|
|
|
Blueprint->SetRegistrationName(RegistrationName);
|
|
|
|
|
FText DisplayName = FText::FromString(Blueprint->GetName());
|
2019-06-04 15:42:48 -04:00
|
|
|
if (LevelEditorTabManager && !LevelEditorTabManager->HasTabSpawner(RegistrationName))
|
2019-05-08 13:56:41 -04:00
|
|
|
{
|
|
|
|
|
LevelEditorTabManager->RegisterTabSpawner(RegistrationName, FOnSpawnTab::CreateUObject(Blueprint, &UEditorUtilityWidgetBlueprint::SpawnEditorUITab))
|
|
|
|
|
.SetDisplayName(DisplayName)
|
|
|
|
|
.SetGroup(GetMenuGroup().ToSharedRef());
|
|
|
|
|
CorrectPaths.Add(BlueprintPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogEditorUtilityBlueprint, Warning, TEXT("No generated class for: %s"), *BlueprintPath.ToString());
|
|
|
|
|
}
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
2019-05-08 13:56:41 -04:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogEditorUtilityBlueprint, Warning, TEXT("Expected object of class EditorUtilityWidgetBlueprint: %s"), *BlueprintPath.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogEditorUtilityBlueprint, Warning, TEXT("Could not load: %s"), *BlueprintPath.ToString());
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
|
|
|
|
}
|
2019-02-27 10:39:53 -05:00
|
|
|
|
2019-05-08 18:48:36 -04:00
|
|
|
EditorUtilitySubsystem->LoadedUIs = CorrectPaths;
|
|
|
|
|
EditorUtilitySubsystem->SaveConfig();
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
|
|
|
|
|
2018-09-05 17:26:48 -04:00
|
|
|
void OnMapChanged(UWorld* InWorld, EMapChangeType MapChangeType)
|
2018-09-05 17:18:42 -04:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
for (const FSoftObjectPath& LoadedUI : GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>()->LoadedUIs)
|
2018-09-05 17:18:42 -04:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
UEditorUtilityWidgetBlueprint* LoadedEditorUtilityBlueprint = Cast<UEditorUtilityWidgetBlueprint>(LoadedUI.ResolveObject());
|
|
|
|
|
if (LoadedEditorUtilityBlueprint)
|
2018-09-05 17:18:42 -04:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
UEditorUtilityWidget* CreatedWidget = LoadedEditorUtilityBlueprint->GetCreatedWidget();
|
|
|
|
|
if (CreatedWidget)
|
2018-09-05 17:18:42 -04:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
if (MapChangeType == EMapChangeType::TearDownWorld)
|
2018-09-05 17:18:42 -04:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
CreatedWidget->Rename(*CreatedWidget->GetName(), GetTransientPackage());
|
|
|
|
|
}
|
|
|
|
|
else if (MapChangeType == EMapChangeType::LoadMap || MapChangeType == EMapChangeType::NewMap)
|
|
|
|
|
{
|
|
|
|
|
UWorld* World = GEditor->GetEditorWorldContext().World();
|
|
|
|
|
check(World);
|
|
|
|
|
CreatedWidget->Rename(*CreatedWidget->GetName(), World);
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void ShutdownModule() override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
if (!UObjectInitialized())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 17:18:42 -04:00
|
|
|
// Unregister widget blueprint compiler we do this no matter what.
|
|
|
|
|
IUMGEditorModule& UMGEditorModule = FModuleManager::LoadModuleChecked<IUMGEditorModule>("UMGEditor");
|
|
|
|
|
IKismetCompilerInterface& KismetCompilerModule = FModuleManager::LoadModuleChecked<IKismetCompilerInterface>("KismetCompiler");
|
|
|
|
|
KismetCompilerModule.GetCompilers().Remove(UMGEditorModule.GetRegisteredCompiler());
|
|
|
|
|
|
2018-02-22 11:25:06 -05:00
|
|
|
FBlutilityLevelEditorExtensions::RemoveHooks();
|
|
|
|
|
FBlutilityContentBrowserExtensions::RemoveHooks();
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
// Only unregister if the asset tools module is loaded. We don't want to forcibly load it during shutdown phase.
|
|
|
|
|
check( EditorBlueprintAssetTypeActions.IsValid() );
|
|
|
|
|
if (FModuleManager::Get().IsModuleLoaded("AssetTools"))
|
|
|
|
|
{
|
2018-09-05 17:18:42 -04:00
|
|
|
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
|
|
|
|
AssetTools.UnregisterAssetTypeActions(EditorBlueprintAssetTypeActions.ToSharedRef());
|
|
|
|
|
AssetTools.UnregisterAssetTypeActions(EditorWidgetBlueprintAssetTypeActions.ToSharedRef());
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
EditorBlueprintAssetTypeActions.Reset();
|
2018-09-05 17:18:42 -04:00
|
|
|
EditorWidgetBlueprintAssetTypeActions.Reset();
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-02-13 17:03:46 -05:00
|
|
|
FEditorSupportDelegates::PrepareToCleanseEditorObject.RemoveAll(this);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2019-03-12 10:10:00 -04:00
|
|
|
virtual bool IsEditorUtilityBlueprint( const UBlueprint* Blueprint ) const override
|
2015-01-05 08:55:15 -05:00
|
|
|
{
|
|
|
|
|
const UClass* BPClass = Blueprint ? Blueprint->GetClass() : nullptr;
|
|
|
|
|
|
2019-03-12 10:10:00 -04:00
|
|
|
if( BPClass &&
|
|
|
|
|
(BPClass->IsChildOf( UEditorUtilityBlueprint::StaticClass())
|
|
|
|
|
|| BPClass->IsChildOf(UEditorUtilityWidgetBlueprint::StaticClass())))
|
2015-01-05 08:55:15 -05:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 17:18:42 -04:00
|
|
|
virtual TSharedPtr<class FWorkspaceItem> GetMenuGroup() const override
|
|
|
|
|
{
|
|
|
|
|
return ScriptedEditorWidgetsGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual EAssetTypeCategories::Type GetAssetCategory() const override
|
|
|
|
|
{
|
|
|
|
|
return EditorUtilityAssetCategory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void AddLoadedScriptUI(class UEditorUtilityWidgetBlueprint* InBlueprint) override
|
|
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
|
|
|
|
|
EditorUtilitySubsystem->LoadedUIs.AddUnique(InBlueprint);
|
|
|
|
|
EditorUtilitySubsystem->SaveConfig();
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void RemoveLoadedScriptUI(class UEditorUtilityWidgetBlueprint* InBlueprint) override
|
|
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
|
|
|
|
|
EditorUtilitySubsystem->LoadedUIs.Remove(InBlueprint);
|
|
|
|
|
EditorUtilitySubsystem->SaveConfig();
|
2018-09-05 17:18:42 -04:00
|
|
|
}
|
2019-02-27 10:40:48 -05:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
protected:
|
2018-09-05 17:18:42 -04:00
|
|
|
|
|
|
|
|
virtual void AddReferencedObjects(FReferenceCollector& Collector) override
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-04-29 19:32:06 -04:00
|
|
|
virtual FString GetReferencerName() const override
|
|
|
|
|
{
|
|
|
|
|
return TEXT("FBlutilityModule");
|
|
|
|
|
}
|
2018-09-05 17:18:42 -04:00
|
|
|
|
2019-02-13 17:03:46 -05:00
|
|
|
void OnPrepareToCleanseEditorObject(UObject* InObject)
|
|
|
|
|
{
|
|
|
|
|
// Gather the list of live Editor Utility instances to purge references from
|
|
|
|
|
TArray<UObject*> EditorUtilityInstances;
|
|
|
|
|
ForEachObjectOfClass(UEditorUtilityWidget::StaticClass(), [&EditorUtilityInstances](UObject* InEditorUtilityInstance)
|
|
|
|
|
{
|
|
|
|
|
EditorUtilityInstances.Add(InEditorUtilityInstance);
|
|
|
|
|
});
|
2019-04-09 16:17:53 -04:00
|
|
|
ForEachObjectOfClass(UDEPRECATED_GlobalEditorUtilityBase::StaticClass(), [&EditorUtilityInstances](UObject* InEditorUtilityInstance)
|
2019-02-13 17:03:46 -05:00
|
|
|
{
|
|
|
|
|
EditorUtilityInstances.Add(InEditorUtilityInstance);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (EditorUtilityInstances.Num() > 0)
|
|
|
|
|
{
|
|
|
|
|
// Build up the complete list of objects to purge
|
|
|
|
|
FPurgingReferenceCollector PurgingReferenceCollector;
|
|
|
|
|
PurgingReferenceCollector.AddObjectToPurge(InObject);
|
|
|
|
|
ForEachObjectWithOuter(InObject, [&PurgingReferenceCollector](UObject* InInnerObject)
|
|
|
|
|
{
|
|
|
|
|
PurgingReferenceCollector.AddObjectToPurge(InInnerObject);
|
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
// Run the purge for each Editor Utility instance
|
|
|
|
|
FReferenceCollectorArchive& PurgingReferenceCollectorArchive = PurgingReferenceCollector.GetVerySlowReferenceCollectorArchive();
|
|
|
|
|
for (UObject* EditorUtilityInstance : EditorUtilityInstances)
|
|
|
|
|
{
|
|
|
|
|
PurgingReferenceCollectorArchive.SetSerializingObject(EditorUtilityInstance);
|
|
|
|
|
EditorUtilityInstance->Serialize(PurgingReferenceCollectorArchive);
|
|
|
|
|
EditorUtilityInstance->CallAddReferencedObjects(PurgingReferenceCollector);
|
|
|
|
|
PurgingReferenceCollectorArchive.SetSerializingObject(nullptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 10:40:48 -05:00
|
|
|
void HandleAssetRemoved(const FAssetData& InAssetData)
|
|
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
bool bDeletingLoadedUI = false;
|
|
|
|
|
for (const FSoftObjectPath& LoadedUIPath : GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>()->LoadedUIs)
|
2019-02-27 10:40:48 -05:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
if (LoadedUIPath.GetAssetPathName() == InAssetData.ObjectPath)
|
2019-02-27 10:40:48 -05:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
bDeletingLoadedUI = true;
|
|
|
|
|
break;
|
2019-02-27 10:40:48 -05:00
|
|
|
}
|
2019-05-08 18:48:36 -04:00
|
|
|
}
|
2019-02-27 10:40:48 -05:00
|
|
|
|
2019-05-08 18:48:36 -04:00
|
|
|
if (bDeletingLoadedUI)
|
|
|
|
|
{
|
|
|
|
|
FName UIToCleanup = FName(*(InAssetData.ObjectPath.ToString() + LOCTEXT("ActiveTabSuffix", "_ActiveTab").ToString()));
|
|
|
|
|
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
|
|
|
|
|
TSharedPtr<FTabManager> LevelEditorTabManager = LevelEditorModule.GetLevelEditorTabManager();
|
|
|
|
|
TSharedPtr<SDockTab> CurrentTab = LevelEditorTabManager->FindExistingLiveTab(UIToCleanup);
|
|
|
|
|
if (CurrentTab.IsValid())
|
2019-02-27 10:40:48 -05:00
|
|
|
{
|
2019-05-08 18:48:36 -04:00
|
|
|
CurrentTab->RequestCloseTab();
|
2019-02-27 10:40:48 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected:
|
2018-09-05 17:18:42 -04:00
|
|
|
/** Scripted Editor Widgets workspace menu item */
|
|
|
|
|
TSharedPtr<class FWorkspaceItem> ScriptedEditorWidgetsGroup;
|
|
|
|
|
|
|
|
|
|
EAssetTypeCategories::Type EditorUtilityAssetCategory;
|
2014-03-14 14:13:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_MODULE( FBlutilityModule, Blutility );
|
2018-09-05 17:18:42 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|