From f91e64074160a17a81bac5a022b69a47c7bf23d5 Mon Sep 17 00:00:00 2001 From: sconel Date: Wed, 23 Jun 2021 16:57:57 -0700 Subject: [PATCH 1/2] Fix issue where new projects would crash when entering game mode --- .../PrefabEditorEntityOwnershipService.cpp | 17 +++++++++++++++-- Gems/Multiplayer/Code/CMakeLists.txt | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp index d9cfe3f340..9dd438e2fc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp @@ -504,7 +504,7 @@ namespace AzToolsFramework copy.CopyFrom(templateReference->get().GetPrefabDom(), copy.GetAllocator(), false); context.AddPrefab(DefaultMainSpawnableName, AZStd::move(copy)); m_playInEditorData.m_converter.ProcessPrefab(context); - if (context.HasCompletedSuccessfully()) + if (context.HasCompletedSuccessfully() && !context.GetProcessedObjects().empty()) { static constexpr size_t NoRootSpawnable = AZStd::numeric_limits::max(); size_t rootSpawnableIndex = NoRootSpawnable; @@ -551,6 +551,13 @@ namespace AzToolsFramework m_playInEditorData.m_entities.Reset(m_playInEditorData.m_assets[rootSpawnableIndex]); m_playInEditorData.m_entities.SpawnAllEntities(); } + else + { + AZ_Error("Prefab", false, + "Processing of the level prefab failed to produce a root spawnable while entering game mode." + "Unable to fully enter game mode."); + return; + } // This is a workaround until the replacement for GameEntityContext is done AzFramework::GameEntityContextEventBus::Broadcast( @@ -558,7 +565,9 @@ namespace AzToolsFramework } else { - AZ_Error("Prefab", false, "Failed to convert the prefab into assets."); + AZ_Error("Prefab", false, + "Failed to convert the prefab into assets. " + "Confirm that the 'PlayInEditor' prefab processor stack is capable of producing a useable product asset."); return; } } @@ -596,6 +605,10 @@ namespace AzToolsFramework } m_playInEditorData.m_deactivatedEntities.clear(); + AZ_Assert(m_playInEditorData.m_entities.IsSet(), + "Invalid Game Mode Entities Container encountered after play-in-editor stopped. " + "Confirm that the container was initialized correctly"); + m_playInEditorData.m_entities.DespawnAllEntities(); m_playInEditorData.m_entities.Alert( [assets = AZStd::move(m_playInEditorData.m_assets)]([[maybe_unused]]uint32_t generation) mutable diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index 4d9635f3b5..42de715cd2 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -151,7 +151,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) ) # use the Multiplayer.Editor module in tools like the Editor: Such tools also get the visual debug view: - ly_create_alias(NAME Multiplayer.Tools NAMESPACE Gem TARGETS Gem::Multiplayer.Editor Gem::Multiplayer.Debug) + ly_create_alias(NAME Multiplayer.Tools NAMESPACE Gem TARGETS Gem::Multiplayer.Editor Gem::Multiplayer.Debug Gem::Multiplayer.Builders) endif() if (PAL_TRAIT_BUILD_TESTS_SUPPORTED) From ad181205f8990d1d831228eb054ece0eafabba2e Mon Sep 17 00:00:00 2001 From: sconel Date: Wed, 23 Jun 2021 17:06:13 -0700 Subject: [PATCH 2/2] Add extra space to error message for better formatting --- .../Entity/PrefabEditorEntityOwnershipService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp index 9dd438e2fc..c308a73874 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp @@ -554,7 +554,7 @@ namespace AzToolsFramework else { AZ_Error("Prefab", false, - "Processing of the level prefab failed to produce a root spawnable while entering game mode." + "Processing of the level prefab failed to produce a root spawnable while entering game mode. " "Unable to fully enter game mode."); return; }