Merge pull request #1539 from aws-lumberyard-dev/Prefabs/GameModeNewProjectCrash
Fix issue where new projects would crash when exiting game mode
This commit is contained in:
+15
-2
@@ -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<size_t>::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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user