-
Notifications
You must be signed in to change notification settings - Fork 450
fix: Add OnPreShutdown to NetworkManager #3358
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor side note, you don't need to set it to null as that is the default value when the NetworkManager class is instantiated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I just figured I'd keep it consistent with the other events.
Updating this for v1.x since all tests are public.
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 <[email protected]>
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 theNetworkManager
during shutdown, such as accessing dynamically spawned NetworkObjects.fix: #3145
close: #3145
Changelog
Testing and Documentation