Skip to content

Commit fc50f4d

Browse files
committed
Handle GameObject being deleted before load thread finishes
1 parent 852ebae commit fc50f4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

native~/Runtime/src/UnityPrepareRendererResources.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,15 @@ UnityPrepareRendererResources::prepareInLoadThread(
920920
.thenInMainThread(
921921
[asyncSystem, tileset = this->_tilesetGameObject](
922922
IntermediateLoadThreadResult&& workerResult) mutable {
923+
if (tileset == nullptr) {
924+
// Tileset GameObject was deleted while we were loading a tile
925+
// (possibly play mode was exited or another cause).
926+
return asyncSystem.createResolvedFuture(
927+
TileLoadResultAndRenderResources{
928+
std::move(workerResult.tileLoadResult),
929+
nullptr});
930+
}
931+
923932
bool shouldCreatePhysicsMeshes = false;
924933
bool shouldShowTilesInHierarchy = false;
925934

0 commit comments

Comments
 (0)