Skip to content

fix: OnNetworkDespawn not called during shutdown (#1390) #1460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

andrews-unity
Copy link
Contributor

Original PR: #1390

* fix

Renaming and refactoring DestroyNonSceneObjects to be DespawnNetworkObjects as this is really what it is doing.  The destroy portion is either up to the handler, if an in-scene NetworkObject it lets the unloading of the scene destroy it, and the rest are always destroyed.

* fix

updates to the changes in NetworkSpawnManager

* fix

Adding a "ShutdownInProgress" flag to be able to easily check if we are shutting down.

Adding a check for the NetworkManager.LocalClient since we are despawning in the shutdown method.

Ignoring the de-parenting of NetworkObjects when shutting down (this will have to be discussed a bit).

* fix

Test fix:  I think this was just an unexposed bug in the NetworkRigidBody2D test, but will verify this before making this final.

Fixed some additional minor issues like checking for IsSpawned as opposed to NetworkManager.IsListening and IsSpawned as opposed to NetworkObject.IsSpawned.

* fix

Avoiding spam when despawning and shutting down.
Renaming DespawnNetworkObjects to DespawnAndDestroyNetworkObjects.
If a NetworkObject is not spawned it gets destroyed.

* test fix

Fixing issue with editor tests and the NetworkManager.Singleton instance.

* fix

Adjusting the logic a bit on getting the NetworkObject associated with a NetworkBehaviour.

* revert and fix

After discussing this with Luke, it turned out there was a bug in the NetworkRigidBody2D where it was resetting the isKinematic to true.  This reverts the changes made to the NetworkRigidbody2DDynamicTest and fixes the bug with NetworkRigidBody2D.

* test

Tests that validate OnNetworkDespawn is invoked during shutdown.
This tests server, host, and client relative instances.

* update changelog

update the changelog with the fixed information

* fix

fixing issue with test and recent changes for when the internal shutdown method is invoked.

* refactor

ShutdownInProgress now returns m_ShuttingDown.

Setting m_ShuttingDown to false at the end of ShutdownInternal in case the NetworkManager is going to be re-used.

* style

line endings

* Revert "style"

This reverts commit e2ca11a.

* fix

fixing timing related issue for NetworkObjectOnNetworkDespawnTests.
@andrews-unity andrews-unity enabled auto-merge (squash) November 24, 2021 12:06
@andrews-unity andrews-unity merged commit 2ad7ccb into release/1.0.0 Nov 25, 2021
@andrews-unity andrews-unity deleted the backport/1.0.0-fix-OnNetworkDespawn-Not-Called-During-Shutdown branch November 25, 2021 16:00
mollstam pushed a commit to Keepsake-Games/com.unity.netcode.gameobjects that referenced this pull request Feb 13, 2023
…1390) (Unity-Technologies#1460)

* fix

Renaming and refactoring DestroyNonSceneObjects to be DespawnNetworkObjects as this is really what it is doing.  The destroy portion is either up to the handler, if an in-scene NetworkObject it lets the unloading of the scene destroy it, and the rest are always destroyed.

* fix

updates to the changes in NetworkSpawnManager

* fix

Adding a "ShutdownInProgress" flag to be able to easily check if we are shutting down.

Adding a check for the NetworkManager.LocalClient since we are despawning in the shutdown method.

Ignoring the de-parenting of NetworkObjects when shutting down (this will have to be discussed a bit).

* fix

Test fix:  I think this was just an unexposed bug in the NetworkRigidBody2D test, but will verify this before making this final.

Fixed some additional minor issues like checking for IsSpawned as opposed to NetworkManager.IsListening and IsSpawned as opposed to NetworkObject.IsSpawned.

* fix

Avoiding spam when despawning and shutting down.
Renaming DespawnNetworkObjects to DespawnAndDestroyNetworkObjects.
If a NetworkObject is not spawned it gets destroyed.

* test fix

Fixing issue with editor tests and the NetworkManager.Singleton instance.

* fix

Adjusting the logic a bit on getting the NetworkObject associated with a NetworkBehaviour.

* revert and fix

After discussing this with Luke, it turned out there was a bug in the NetworkRigidBody2D where it was resetting the isKinematic to true.  This reverts the changes made to the NetworkRigidbody2DDynamicTest and fixes the bug with NetworkRigidBody2D.

* test

Tests that validate OnNetworkDespawn is invoked during shutdown.
This tests server, host, and client relative instances.

* update changelog

update the changelog with the fixed information

* fix

fixing issue with test and recent changes for when the internal shutdown method is invoked.

* refactor

ShutdownInProgress now returns m_ShuttingDown.

Setting m_ShuttingDown to false at the end of ShutdownInternal in case the NetworkManager is going to be re-used.

* style

line endings

* Revert "style"

This reverts commit e2ca11a.

* fix

fixing timing related issue for NetworkObjectOnNetworkDespawnTests.

Co-authored-by: Noel Stephens <noel.stephens@unity3d.com>
Co-authored-by: Unity Netcode CI <74025435+netcode-ci-service@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants