diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index 55961aa703..014bade347 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -963,18 +963,22 @@ namespace AzToolsFramework if (!m_parentEntityId.IsValid()) { - // If Prefabs are enabled, reroute the invalid id to the level root + // If Prefabs are enabled, reroute the invalid id to the focused prefab container entity id bool isPrefabSystemEnabled = false; AzFramework::ApplicationRequests::Bus::BroadcastResult( isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); if (isPrefabSystemEnabled) { - auto prefabPublicInterface = AZ::Interface::Get(); + auto prefabFocusPublicInterface = AZ::Interface::Get(); - if (prefabPublicInterface) + if (prefabFocusPublicInterface) { - m_parentEntityId = prefabPublicInterface->GetLevelInstanceContainerEntityId(); + auto editorEntityContextId = AzFramework::EntityContextId::CreateNull(); + EditorEntityContextRequestBus::BroadcastResult( + editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId); + + m_parentEntityId = prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(editorEntityContextId); refreshLevel = AZ::Edit::PropertyRefreshLevels::ValuesOnly; } }