|
18 | 18 | #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
19 | 19 | #include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
20 | 20 | #include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
| 21 | +#include <AzToolsFramework/Entity/EditorEntitySortComponent.h> |
21 | 22 | #include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
22 | 23 | #include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
23 | 24 | #include <AzToolsFramework/Prefab/EditorPrefabComponent.h>
|
|
36 | 37 | #include <AzToolsFramework/Prefab/Undo/PrefabUndoUpdateLink.h>
|
37 | 38 | #include <AzToolsFramework/Prefab/PrefabUndoHelpers.h>
|
38 | 39 | #include <AzToolsFramework/ToolsComponents/TransformComponent.h>
|
39 |
| -#include <AzToolsFramework/Entity/EditorEntitySortComponent.h> |
| 40 | +#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h> |
40 | 41 |
|
41 | 42 | #include <QString>
|
| 43 | +#include <QTimer> |
42 | 44 |
|
43 | 45 | namespace AzToolsFramework
|
44 | 46 | {
|
45 | 47 | namespace Prefab
|
46 | 48 | {
|
| 49 | + PrefabPublicHandler::PrefabPublicHandler() |
| 50 | + { |
| 51 | + // Detect whether this is being run in the Editor or during a Unit Test. |
| 52 | + AZ::ApplicationTypeQuery appType; |
| 53 | + AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::QueryApplicationType, appType); |
| 54 | + m_isRunningInEditor = (!appType.IsValid() || appType.IsEditor()); |
| 55 | + } |
| 56 | + |
47 | 57 | void PrefabPublicHandler::RegisterPrefabPublicHandlerInterface()
|
48 | 58 | {
|
49 | 59 | m_prefabFocusHandler.RegisterPrefabFocusInterface();
|
@@ -1340,8 +1350,25 @@ namespace AzToolsFramework
|
1340 | 1350 | // Select the duplicated entities/instances
|
1341 | 1351 | auto selectionUndo = aznew SelectionCommand(duplicatedEntityAndInstanceIds, "Select Duplicated Entities/Instances");
|
1342 | 1352 | selectionUndo->SetParent(undoBatch.GetUndoBatch());
|
1343 |
| - ToolsApplicationRequestBus::Broadcast( |
1344 |
| - &ToolsApplicationRequestBus::Events::SetSelectedEntities, duplicatedEntityAndInstanceIds); |
| 1353 | + |
| 1354 | + // Only delay selection in the Editor to ensure the manipulators in the viewport are refreshed correctly. |
| 1355 | + if (m_isRunningInEditor) |
| 1356 | + { |
| 1357 | + QTimer::singleShot( |
| 1358 | + 0, |
| 1359 | + [duplicatedEntityAndInstanceIds]() |
| 1360 | + { |
| 1361 | + ToolsApplicationRequestBus::Broadcast( |
| 1362 | + &ToolsApplicationRequestBus::Events::SetSelectedEntities, duplicatedEntityAndInstanceIds); |
| 1363 | + } |
| 1364 | + ); |
| 1365 | + } |
| 1366 | + else |
| 1367 | + { |
| 1368 | + ToolsApplicationRequestBus::Broadcast( |
| 1369 | + &ToolsApplicationRequestBus::Events::SetSelectedEntities, duplicatedEntityAndInstanceIds); |
| 1370 | + } |
| 1371 | + |
1345 | 1372 | }
|
1346 | 1373 |
|
1347 | 1374 | return AZ::Success(AZStd::move(duplicatedEntityAndInstanceIds));
|
|
0 commit comments