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>
42
43
#include < QTimer>
@@ -45,6 +46,14 @@ namespace AzToolsFramework
45
46
{
46
47
namespace Prefab
47
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
+
48
57
void PrefabPublicHandler::RegisterPrefabPublicHandlerInterface ()
49
58
{
50
59
m_prefabFocusHandler.RegisterPrefabFocusInterface ();
@@ -1342,14 +1351,24 @@ namespace AzToolsFramework
1342
1351
auto selectionUndo = aznew SelectionCommand (duplicatedEntityAndInstanceIds, " Select Duplicated Entities/Instances" );
1343
1352
selectionUndo->SetParent (undoBatch.GetUndoBatch ());
1344
1353
1345
- QTimer::singleShot (
1346
- 0 ,
1347
- [duplicatedEntityAndInstanceIds]()
1348
- {
1349
- ToolsApplicationRequestBus::Broadcast (
1350
- &ToolsApplicationRequestBus::Events::SetSelectedEntities, duplicatedEntityAndInstanceIds);
1351
- }
1352
- );
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
+
1353
1372
}
1354
1373
1355
1374
return AZ::Success (AZStd::move (duplicatedEntityAndInstanceIds));
0 commit comments