Commit 7346a2f
authored
fix: ServerDestroySpawnedSceneObjects throws an exception before switching scene (#618)
* fix: crash during scene transition
If you have in-scene placed NetworkObjects and you transition to a new scene then a crash will occur in NetworkSpawnManager.ServerDestroySpawnedSceneObjects due to NetworkObjects being removed from the SpawnedObjectsList during the "OnDestroy" invocation. This fixes that crash.
* style: comments and standards
Adding some comments as to why the code is added, camelCase for locals, and generic Var as opposed to specific type for declaration.
* refactor: comments and better approach
This applies a better approach to the issue of removing objects from a list that is being iterated over without throwing the "Collection was modified; enumeration operation may not execute" exception due to NetworkObjects removing themselves from the SpawnedObjectList during OnDestroy.
* refactor: comment
Minor tweak to the comment as to why the code was added.1 parent 28f81d6 commit 7346a2f
File tree
1 file changed
+10
-1
lines changed- com.unity.multiplayer.mlapi/Runtime/Spawning
1 file changed
+10
-1
lines changedLines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
544 | 547 | | |
545 | 548 | | |
546 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
547 | 554 | | |
548 | 555 | | |
549 | 556 | | |
550 | 557 | | |
551 | 558 | | |
| 559 | + | |
552 | 560 | | |
553 | 561 | | |
554 | 562 | | |
555 | 563 | | |
556 | 564 | | |
| 565 | + | |
557 | 566 | | |
558 | 567 | | |
559 | 568 | | |
| |||
0 commit comments