-
Notifications
You must be signed in to change notification settings - Fork 462
fix: avoid throwing exception when using NetworkList without a NetworkManager (#2539) #2540
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
fix: avoid throwing exception when using NetworkList without a NetworkManager (#2539) #2540
Conversation
6081b6e to
b1feb94
Compare
com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs
Outdated
Show resolved
Hide resolved
8dc63f2 to
844acdb
Compare
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.
Thank you for your contribution and your patience on this review.
To be able to land this PR we will also need a forward-port PR for the develop-2.0.0 branch as we cannot have bug fixes in older versions that are not also in newer versions.
com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs
Outdated
Show resolved
Hide resolved
844acdb to
fd18093
Compare
|
Thanks for the update! Just to check that we're not landing an incomplete fix, have you used this branch with your project? Does it resolve the issue you're needing resolved? |
fd18093 to
5e06bf1
Compare
|
Yes, I do use this fix in my project for two years. This PR just adds the same check as you already do in the NetworkVariable here: Line 148 in 7ed7a52
I also have rebased my branch. |
|
This change has been imported into #3502 so we can run the change through our validation process. Thanks for your contribution! Feel free to review if I have missed something. |
…kManager (#3502) <!-- Replace this block with what this PR does and why. Describe what you'd like reviewers to know, how you applied the engineering principles, and any interesting tradeoffs made. Delete bullet points below that don't apply, and update the changelog section as appropriate. --> <!-- Add short version of the JIRA ticket to the PR title (e.g. "feat: new shiny feature [MTT-123]") --> Continues #2540 Fixes #2539 ## Changelog - Added: `LocalClientCannotWrite` function to co-locate the shared functionality - Fixed: Ensure that the `NetworkManager` exists before attempting to access the `LocalClientId` ## Testing and Documentation - No tests have been added. <!-- 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. --> ## Backport <!-- If this is a backport: - Add the following to the PR title: "\[Backport\] ..." . - Link to the original PR. If this needs a backport - state this here If a backport is not needed please provide the reason why. If the "Backports" section is not present it will lead to a CI test failure. --> Up-ported in #3503 --------- Co-authored-by: PitouGames <[email protected]>
Resolve #2539
This PR add a check that m_NetworkBehaviour is not null before calling the
CanClientWritefunction.I did it exactly the same way it's already done for NetworkVariable.
With this PR, operations on the list are done and throws the anyoning warning (
NetworkVariable<T>do the same)Changelog
NetworkListthrowing exception when used without a NetworkManager in scene. (Can't do operations onNetworkListwith noNetworkManager(offline) #2539)Testing and Documentation