From 06868f76afc1b35d39fe71992a0504ea4a6a5bfb Mon Sep 17 00:00:00 2001 From: Lukasz 'iniside' Baran Date: Wed, 3 Jul 2019 13:13:12 +0200 Subject: [PATCH 1/9] fix prefab collection placement/randomization. It was not working because IsValid() check for valid pointer, should be !IsNull() to check if asset can EVER be valid after loading --- .../Private/Asset/PrefabricatorAsset.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp b/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp index 5a552eaf..ac4b80d1 100644 --- a/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp +++ b/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp @@ -110,11 +110,12 @@ UPrefabricatorAsset* UPrefabricatorAssetCollection::GetPrefabAsset(const FPrefab } StartRange = EndRange; } - if (!PrefabAssetPtr.IsValid()) { + if (!PrefabAssetPtr.IsNull()) { PrefabAssetPtr = Prefabs.Last().PrefabAsset; } } - if (PrefabAssetPtr.IsValid()) { + + if (!PrefabAssetPtr.IsNull()) { return PrefabAssetPtr.LoadSynchronous(); } return nullptr; From 01cde9e4376dc91c5ed4146d7e733ea4ab5d7dc0 Mon Sep 17 00:00:00 2001 From: Lukasz 'iniside' Baran Date: Wed, 3 Jul 2019 13:16:45 +0200 Subject: [PATCH 2/9] remove ! from IsNull check --- .../PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp b/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp index ac4b80d1..679d9a0e 100644 --- a/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp +++ b/Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp @@ -110,7 +110,7 @@ UPrefabricatorAsset* UPrefabricatorAssetCollection::GetPrefabAsset(const FPrefab } StartRange = EndRange; } - if (!PrefabAssetPtr.IsNull()) { + if (PrefabAssetPtr.IsNull()) { PrefabAssetPtr = Prefabs.Last().PrefabAsset; } } From 9bf1a95f8d653236984404a507c98b0df0b57d81 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Wed, 31 Jul 2019 13:08:52 +0200 Subject: [PATCH 3/9] Add filter to select only prefabs when using recangular selection in viewport --- .../Private/PrefabEditorCommands.cpp | 10 +++++++++ .../Private/PrefabricatorEditorModule.cpp | 21 ++++++++++++++++++- .../Private/UI/EditorUIExtender.cpp | 1 + .../Public/PrefabEditorCommands.h | 2 +- .../Public/PrefabricatorEditorModule.h | 4 +--- .../Private/Prefab/PrefabTools.cpp | 15 +++++++++++++ .../Public/Prefab/PrefabTools.h | 3 +++ .../Public/PrefabricatorSettings.h | 3 +++ 8 files changed, 54 insertions(+), 5 deletions(-) diff --git a/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp b/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp index 406883f3..88e56672 100644 --- a/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp +++ b/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp @@ -9,6 +9,7 @@ #include "Framework/Commands/UIAction.h" #include "Framework/Commands/UICommandList.h" #include "UObject/Object.h" +#include "PrefabricatorEditorModule.h" #define LOCTEXT_NAMESPACE "ContentBrowser" @@ -30,6 +31,15 @@ void FPrefabricatorCommands::RegisterCommands() { FExecuteAction::CreateStatic(&FPrefabTools::CreatePrefab), FCanExecuteAction::CreateStatic(&FPrefabTools::CanCreatePrefab) ); + + UI_COMMAND(AllowOnlyPrefabSelection, "Select Only Prefabs", "Allow only prefabs to be selected", EUserInterfaceActionType::ToggleButton, FInputChord(EKeys::NumPadOne)); + + LevelMenuActionList->MapAction( + AllowOnlyPrefabSelection + , FExecuteAction::CreateStatic(&FPrefabTools::SetAllowOnlyPrefabSelection) + , FCanExecuteAction() + , FIsActionChecked::CreateStatic(&FPrefabTools::GetAllowOnlyPrefabSelection) + ); } diff --git a/Source/PrefabricatorEditor/Private/PrefabricatorEditorModule.cpp b/Source/PrefabricatorEditor/Private/PrefabricatorEditorModule.cpp index 72b76881..5a37eb3a 100644 --- a/Source/PrefabricatorEditor/Private/PrefabricatorEditorModule.cpp +++ b/Source/PrefabricatorEditor/Private/PrefabricatorEditorModule.cpp @@ -23,7 +23,8 @@ #include "PropertyEditorModule.h" #include "ThumbnailRendering/ThumbnailManager.h" #include "UnrealEdGlobals.h" - +#include "Engine/Selection.h" +#include "Prefab/PrefabActor.h" #define LOCTEXT_NAMESPACE "PrefabricatorEditorModule" @@ -31,9 +32,11 @@ class FPrefabricatorEditorModule : public IPrefabricatorEditorModule { FPrefabDetailsExtend PrefabActorDetailsExtender; + FDelegateHandle SelectionDelegateHandle; virtual void StartupModule() override { + SelectionDelegateHandle = USelection::SelectObjectEvent.AddRaw(this, &FPrefabricatorEditorModule::OnSelectionChanged); FPrefabEditorStyle::Initialize(); FPrefabricatorCommands::Register(); @@ -129,6 +132,22 @@ class FPrefabricatorEditorModule : public IPrefabricatorEditorModule TSharedPtr PrefabAssetBroker; TArray< TSharedPtr > CreatedAssetTypeActions; EAssetTypeCategories::Type PrefabricatorAssetCategoryBit; + + void OnSelectionChanged(UObject* Object) + { + if(FPrefabTools::GetAllowOnlyPrefabSelection()) + { + APrefabActor* Prefab = Cast(Object); + + if (!Prefab) + { + GEditor->GetSelectedActors()->BeginBatchSelectOperation(); + GEditor->GetSelectedActors()->Select(Object, false); + GEditor->GetSelectedActors()->EndBatchSelectOperation(false); + } + } + + } }; IMPLEMENT_MODULE(FPrefabricatorEditorModule, PrefabricatorEditor) diff --git a/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp b/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp index df8478c8..b4eb5439 100644 --- a/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp +++ b/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp @@ -150,6 +150,7 @@ void FEditorUIExtender::Extend() MenuBuilder.BeginSection("Prefabricator-Prefabs", LOCTEXT("PrefabHeader", "Prefabs")); MenuBuilder.AddMenuEntry(FPrefabricatorCommands::Get().CreatePrefab); + MenuBuilder.AddMenuEntry(FPrefabricatorCommands::Get().AllowOnlyPrefabSelection); MenuBuilder.EndSection(); MenuBuilder.BeginSection("Prefabricator-Randomization", LOCTEXT("RandomizationHeader", "Randomization")); diff --git a/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h b/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h index a5ded5f1..ea018b81 100644 --- a/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h +++ b/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h @@ -16,7 +16,7 @@ class PREFABRICATOREDITOR_API FPrefabricatorCommands : public TCommands CreatePrefab; TSharedPtr LevelMenuActionList; - + TSharedPtr< FUICommandInfo > AllowOnlyPrefabSelection; }; diff --git a/Source/PrefabricatorEditor/Public/PrefabricatorEditorModule.h b/Source/PrefabricatorEditor/Public/PrefabricatorEditorModule.h index 8f5c3ab4..940c6049 100644 --- a/Source/PrefabricatorEditor/Public/PrefabricatorEditorModule.h +++ b/Source/PrefabricatorEditor/Public/PrefabricatorEditorModule.h @@ -15,7 +15,6 @@ */ class PREFABRICATOREDITOR_API IPrefabricatorEditorModule : public IModuleInterface { - public: /** @@ -42,5 +41,4 @@ class PREFABRICATOREDITOR_API IPrefabricatorEditorModule : public IModuleInterfa virtual EAssetTypeCategories::Type GetPrefabricatorAssetCategoryBit() const = 0; virtual FPrefabDetailsExtend& GetPrefabActorDetailsExtender() = 0; virtual void UpgradePrefabAssets() = 0; -}; - +}; \ No newline at end of file diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp index 0c74c1a9..0a04870f 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp @@ -17,6 +17,7 @@ #include "Serialization/ObjectAndNameAsStringProxyArchive.h" #include "Serialization/ObjectReader.h" #include "Serialization/ObjectWriter.h" +#include "PrefabricatorSettings.h" DEFINE_LOG_CATEGORY_STATIC(LogPrefabTools, Log, All); @@ -93,6 +94,20 @@ void FPrefabTools::IterateChildrenRecursive(APrefabActor* Prefab, TFunction(); + + // Toggle 'allow select translucent' + Settings->bSelectOnlyPrefabs = !Settings->bSelectOnlyPrefabs; + Settings->PostEditChange(); +} + +bool FPrefabTools::GetAllowOnlyPrefabSelection() +{ + return GetDefault()->bSelectOnlyPrefabs; +} + bool FPrefabTools::CanCreatePrefab() { return GetNumSelectedActors() > 0; diff --git a/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h b/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h index b605e61f..83f4b513 100644 --- a/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h +++ b/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h @@ -43,6 +43,9 @@ class PREFABRICATORRUNTIME_API FPrefabTools { static int32 GetRandomSeed(const FRandomStream& Random); static void IterateChildrenRecursive(APrefabActor* Actor, TFunction Visit); + + static void SetAllowOnlyPrefabSelection(); + static bool GetAllowOnlyPrefabSelection(); }; class PREFABRICATORRUNTIME_API FPrefabVersionControl { diff --git a/Source/PrefabricatorRuntime/Public/PrefabricatorSettings.h b/Source/PrefabricatorRuntime/Public/PrefabricatorSettings.h index 81344cf4..eb242fb6 100644 --- a/Source/PrefabricatorRuntime/Public/PrefabricatorSettings.h +++ b/Source/PrefabricatorRuntime/Public/PrefabricatorSettings.h @@ -30,6 +30,9 @@ class PREFABRICATORRUNTIME_API UPrefabricatorSettings : public UDeveloperSetting UPROPERTY(EditAnywhere, BlueprintReadOnly, config, Category = "Settings") bool bAllowDynamicUpdate; + UPROPERTY(EditAnywhere, BlueprintReadOnly, config, Category = "Settings") + bool bSelectOnlyPrefabs; + public: UPrefabricatorSettings(); From 1fc07241ea467c827b5160939aa758db70621479 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Wed, 31 Jul 2019 13:40:43 +0200 Subject: [PATCH 4/9] fix compilation --- Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp index 0a04870f..dfdebd21 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp @@ -100,7 +100,9 @@ void FPrefabTools::SetAllowOnlyPrefabSelection() // Toggle 'allow select translucent' Settings->bSelectOnlyPrefabs = !Settings->bSelectOnlyPrefabs; +#if WITH_EDITOR Settings->PostEditChange(); +#endif } bool FPrefabTools::GetAllowOnlyPrefabSelection() From 6e997e9d6a32cfbd4cd60053ae57e11987739a44 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Fri, 2 Aug 2019 09:52:13 +0200 Subject: [PATCH 5/9] added new option to create prefab with zeroed pivot. This will allow to easier create prefab randomization, as they are always going to have matched pivot location, regardless of transforms --- .../Private/PrefabEditorCommands.cpp | 10 ++ .../Private/UI/EditorUIExtender.cpp | 1 + .../Public/PrefabEditorCommands.h | 1 + .../Private/Prefab/PrefabTools.cpp | 125 +++++++++++++++++- .../Public/Prefab/PrefabTools.h | 6 +- 5 files changed, 139 insertions(+), 4 deletions(-) diff --git a/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp b/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp index 88e56672..24d47ad2 100644 --- a/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp +++ b/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp @@ -40,6 +40,16 @@ void FPrefabricatorCommands::RegisterCommands() { , FCanExecuteAction() , FIsActionChecked::CreateStatic(&FPrefabTools::GetAllowOnlyPrefabSelection) ); + + + UI_COMMAND(CreatePrefabZeroPivot, "Create Prefab On Zero Oirgin", "Create New prefab on Zeroed pivot", EUserInterfaceActionType::Button, FInputChord(EKeys::NumPadTwo)); + + LevelMenuActionList->MapAction( + CreatePrefabZeroPivot + , FExecuteAction::CreateStatic(&FPrefabTools::CreatePrefabOnZeroPivot) + , FCanExecuteAction() + , FIsActionChecked::CreateStatic(&FPrefabTools::CanCreatePrefab) + ); } diff --git a/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp b/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp index b4eb5439..f609a652 100644 --- a/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp +++ b/Source/PrefabricatorEditor/Private/UI/EditorUIExtender.cpp @@ -150,6 +150,7 @@ void FEditorUIExtender::Extend() MenuBuilder.BeginSection("Prefabricator-Prefabs", LOCTEXT("PrefabHeader", "Prefabs")); MenuBuilder.AddMenuEntry(FPrefabricatorCommands::Get().CreatePrefab); + MenuBuilder.AddMenuEntry(FPrefabricatorCommands::Get().CreatePrefabZeroPivot); MenuBuilder.AddMenuEntry(FPrefabricatorCommands::Get().AllowOnlyPrefabSelection); MenuBuilder.EndSection(); diff --git a/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h b/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h index ea018b81..242ee3c1 100644 --- a/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h +++ b/Source/PrefabricatorEditor/Public/PrefabEditorCommands.h @@ -17,6 +17,7 @@ class PREFABRICATOREDITOR_API FPrefabricatorCommands : public TCommands CreatePrefab; TSharedPtr LevelMenuActionList; TSharedPtr< FUICommandInfo > AllowOnlyPrefabSelection; + TSharedPtr CreatePrefabZeroPivot; }; diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp index dfdebd21..1aeae98c 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp @@ -18,6 +18,7 @@ #include "Serialization/ObjectReader.h" #include "Serialization/ObjectWriter.h" #include "PrefabricatorSettings.h" +#include "Editor.h" DEFINE_LOG_CATEGORY_STATIC(LogPrefabTools, Log, All); @@ -150,7 +151,16 @@ namespace { } } -void FPrefabTools::CreatePrefabFromActors(const TArray& InActors) + +void FPrefabTools::CreatePrefabOnZeroPivot() +{ + TArray SelectedActors; + GetSelectedActors(SelectedActors); + + CreatePrefabFromActorsOnZeroPivot(SelectedActors); +} + +void FPrefabTools::CreatePrefabFromActorsOnZeroPivot(const TArray& InActors) { TArray Actors; SanitizePrefabActorsForCreation(InActors, Actors); @@ -169,10 +179,68 @@ void FPrefabTools::CreatePrefabFromActors(const TArray& InActors) Service->BeginTransaction(LOCTEXT("TransLabel_CreatePrefab", "Create Prefab")); } + UWorld* World = Actors[0]->GetWorld(); - FVector Pivot = FPrefabricatorAssetUtils::FindPivot(Actors); - APrefabActor* PrefabActor = World->SpawnActor(Pivot, FRotator::ZeroRotator); + FVector Pivot = FVector::ZeroVector; + + TArray OriginalActorTransforms; + + for (AActor* A : Actors) + { + OriginalActorTransforms.Add(A->GetTransform()); + FBox BB = A->GetComponentsBoundingBox(); + + A->SetActorRotation(FRotator::ZeroRotator); + } + + { + float LowestZ = MAX_flt; + FBox Bounds(EForceInit::ForceInit); + for (AActor* Actor : Actors) + { + FBox ActorBounds = FPrefabTools::GetPrefabBounds(Actor, false); + Bounds += ActorBounds; + } + + Pivot = Bounds.GetCenter(); + Pivot.Z = Bounds.Min.Z; + } + + FVector RelativePosition = Pivot; + + FActorSpawnParameters SpanParams; + SpanParams.bNoFail = true; + + APrefabActor* PrefabActorTemp = World->SpawnActor(RelativePosition, FRotator::ZeroRotator, SpanParams); + PrefabActorTemp->GetRootComponent()->SetMobility(EComponentMobility::Static); + + //attach to dummy + for (AActor* A : Actors) + { + A->DetachFromActor(FDetachmentTransformRules(EDetachmentRule::KeepWorld, true)); + A->AttachToActor(PrefabActorTemp, FAttachmentTransformRules(EAttachmentRule::KeepWorld, true)); + + FTransform RT = A->GetRootComponent()->GetRelativeTransform(); + + FVector RelLoc = RT.GetLocation(); + } + + //move to world origin + PrefabActorTemp->SetActorLocation(FVector::ZeroVector); + + //detach from dummy. + for (int32 Idx = 0; Idx < Actors.Num(); Idx++) + { + Actors[Idx]->DetachFromActor(FDetachmentTransformRules(EDetachmentRule::KeepWorld, true)); + } + + //we don't need it anymore. + PrefabActorTemp->Destroy(true, true); + + Pivot = FVector::ZeroVector; + + APrefabActor* PrefabActor = World->SpawnActor(FVector::ZeroVector, FRotator::ZeroRotator); // Find the compatible mobility for the prefab actor EComponentMobility::Type Mobility = FPrefabricatorAssetUtils::FindMobility(Actors); @@ -184,6 +252,11 @@ void FPrefabTools::CreatePrefabFromActors(const TArray& InActors) ParentActors(PrefabActor, Actor); } + for (int32 Idx = 0; Idx < Actors.Num(); Idx++) + { + Actors[Idx]->SetActorRotation(OriginalActorTransforms[Idx].GetRotation()); + } + if (Service.IsValid()) { Service->EndTransaction(); } @@ -192,6 +265,52 @@ void FPrefabTools::CreatePrefabFromActors(const TArray& InActors) SelectPrefabActor(PrefabActor); + PrefabActor->SetActorLocation(RelativePosition); +} + +void FPrefabTools::CreatePrefabFromActors(const TArray& InActors) +{ + TArray Actors; + SanitizePrefabActorsForCreation(InActors, Actors); + + if (Actors.Num() == 0) { + return; + } + + UPrefabricatorAsset* PrefabAsset = CreatePrefabAsset(); + if (!PrefabAsset) { + return; + } + + TSharedPtr Service = FPrefabricatorService::Get(); + if (Service.IsValid()) { + Service->BeginTransaction(LOCTEXT("TransLabel_CreatePrefab", "Create Prefab")); + } + + + UWorld* World = Actors[0]->GetWorld(); + + FVector Pivot = FPrefabricatorAssetUtils::FindPivot(Actors); + + APrefabActor* PrefabActor = World->SpawnActor(FVector::ZeroVector, FRotator::ZeroRotator); + + // Find the compatible mobility for the prefab actor + EComponentMobility::Type Mobility = FPrefabricatorAssetUtils::FindMobility(Actors); + PrefabActor->GetRootComponent()->SetMobility(Mobility); + + PrefabActor->PrefabComponent->PrefabAssetInterface = PrefabAsset; + // Attach the actors to the prefab + for (AActor* Actor : Actors) { + ParentActors(PrefabActor, Actor); + } + + if (Service.IsValid()) { + Service->EndTransaction(); + } + + SaveStateToPrefabAsset(PrefabActor); + + SelectPrefabActor(PrefabActor); } void FPrefabTools::AssignAssetUserData(AActor* InActor, const FGuid& InItemID, APrefabActor* Prefab) diff --git a/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h b/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h index 83f4b513..4182bdc8 100644 --- a/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h +++ b/Source/PrefabricatorRuntime/Public/Prefab/PrefabTools.h @@ -19,7 +19,11 @@ class PREFABRICATORRUNTIME_API FPrefabTools { public: static bool CanCreatePrefab(); static void CreatePrefab(); - static void CreatePrefabFromActors(const TArray& Actors); + static void CreatePrefabFromActors(const TArray& InActors); + + static void CreatePrefabOnZeroPivot(); + static void CreatePrefabFromActorsOnZeroPivot(const TArray& Actors); + static void AssignAssetUserData(AActor* InActor, const FGuid& InItemID, APrefabActor* Prefab); static void SaveStateToPrefabAsset(APrefabActor* PrefabActor); From e372e2f02824820be6f78cf6f324fbb6099f27a1 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Fri, 2 Aug 2019 09:57:58 +0200 Subject: [PATCH 6/9] check if we can create prefab on zeroed pivot --- Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp b/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp index 24d47ad2..7bbab215 100644 --- a/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp +++ b/Source/PrefabricatorEditor/Private/PrefabEditorCommands.cpp @@ -47,8 +47,7 @@ void FPrefabricatorCommands::RegisterCommands() { LevelMenuActionList->MapAction( CreatePrefabZeroPivot , FExecuteAction::CreateStatic(&FPrefabTools::CreatePrefabOnZeroPivot) - , FCanExecuteAction() - , FIsActionChecked::CreateStatic(&FPrefabTools::CanCreatePrefab) + , FCanExecuteAction::CreateStatic(&FPrefabTools::CanCreatePrefab) ); } From 2987ff356a9c04f563014888b248b01a56397f73 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Fri, 2 Aug 2019 10:55:09 +0200 Subject: [PATCH 7/9] remove Editor.h include --- Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp index 1aeae98c..80623662 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp @@ -18,7 +18,6 @@ #include "Serialization/ObjectReader.h" #include "Serialization/ObjectWriter.h" #include "PrefabricatorSettings.h" -#include "Editor.h" DEFINE_LOG_CATEGORY_STATIC(LogPrefabTools, Log, All); From bf1e657227f1c81759320ecc3215429ac8fdfe96 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 8 Aug 2019 07:56:44 +0200 Subject: [PATCH 8/9] fix default prefab creation alwyas happening on zero pivot, instead of the bounding box --- Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp index 80623662..5c1089f6 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp @@ -291,7 +291,7 @@ void FPrefabTools::CreatePrefabFromActors(const TArray& InActors) FVector Pivot = FPrefabricatorAssetUtils::FindPivot(Actors); - APrefabActor* PrefabActor = World->SpawnActor(FVector::ZeroVector, FRotator::ZeroRotator); + APrefabActor* PrefabActor = World->SpawnActor(Pivot, FRotator::ZeroRotator); // Find the compatible mobility for the prefab actor EComponentMobility::Type Mobility = FPrefabricatorAssetUtils::FindMobility(Actors); From 792d9fb888c27206f9710467b605ebc158f0f696 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Tue, 13 Aug 2019 14:21:10 +0200 Subject: [PATCH 9/9] fix undo, where in PostEditChangeProperty there was no super call and EditReregisterContexts was never properly cleared --- Source/PrefabricatorRuntime/Private/Prefab/PrefabComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabComponent.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabComponent.cpp index d4183793..21676c6c 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabComponent.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabComponent.cpp @@ -75,7 +75,7 @@ void UPrefabComponent::PostEditChangeProperty(struct FPropertyChangedEvent& e) } } } - + Super::PostEditChangeProperty(e); } #endif // WITH_EDITOR