From af0bfbefdafaf0805f61ac096a7eb337e2cd1b74 Mon Sep 17 00:00:00 2001 From: FoodFish Date: Sun, 3 Dec 2023 16:48:56 -0500 Subject: [PATCH] Fix outdated labels due to SetActorLabel not sending notification --- Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp index 2283628d..2755b86d 100644 --- a/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp +++ b/Source/PrefabricatorRuntime/Private/Prefab/PrefabTools.cpp @@ -661,6 +661,12 @@ void FPrefabTools::LoadActorState(AActor* InActor, const FPrefabricatorActorData #if WITH_EDITOR if (InActorData.ActorName.Len() > 0) { InActor->SetActorLabel(InActorData.ActorName); + // I have found that setting the actor label at the wrong time will result in the label matching underlying data + // but update not being sent. The result is that outdated labels appear in the outliner. Force label update notification to fix this. + InActor->Modify(); + FPropertyChangedEvent PropertyEvent(FindFProperty(AActor::StaticClass(), "ActorLabel")); + InActor->PostEditChangeProperty(PropertyEvent); + FCoreDelegates::OnActorLabelChanged.Broadcast(InActor); } #endif // WITH_EDITOR