fix: Add OnPreShutdown to NetworkManager#3358
Merged
jonathanhertz merged 3 commits intodevelopfrom Mar 26, 2025
Merged
Conversation
NoelStephensUnity
approved these changes
Mar 25, 2025
Member
NoelStephensUnity
left a comment
There was a problem hiding this comment.
Minor nit-pick on the XML API description, but the rest looks good!
| /// Subscribe to this static event to get notifications before a <see cref="NetworkManager"/> instance is being destroyed. | ||
| /// This is useful if you want to use the state of anything the NetworkManager cleans up during its shutdown. | ||
| /// </summary> | ||
| public event Action OnPreShutdown = null; |
Member
There was a problem hiding this comment.
Minor side note, you don't need to set it to null as that is the default value when the NetworkManager class is instantiated.
Contributor
Author
There was a problem hiding this comment.
True, I just figured I'd keep it consistent with the other events.
Updating this for v1.x since all tests are public.
NoelStephensUnity
added a commit
that referenced
this pull request
Mar 29, 2025
Forwardport of #3358 This PR adds a `NetworkManager.OnPreShutdown` callback that happens before the internal shutdown is done. This is to allow accessing any state that is cleaned up by the `NetworkManager` during shutdown, such as accessing dynamically spawned NetworkObjects. ## Changelog - Added: The event NetworkManager.OnPreShutdown has been added which is called before the NetworkManager cleans up and shuts down. ## Testing and Documentation - A test has been added to ensure this is being called, and called before OnServerStopped. <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> --------- Co-authored-by: Noel Stephens <noel.stephens@unity3d.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
NetworkManager.OnPreShutdowncallback that happens before the internal shutdown is done. This is to allow accessing any state that is cleaned up by theNetworkManagerduring shutdown, such as accessing dynamically spawned NetworkObjects.fix: #3145
close: #3145
Changelog
Testing and Documentation