-
Notifications
You must be signed in to change notification settings - Fork 450
fix: NetworkManager always sent to the DDOL and cannot be nested #1484
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: NetworkManager always sent to the DDOL and cannot be nested #1484
Conversation
Added the two changes made for NetworkManager.
@@ -1699,5 +1701,151 @@ internal void ApprovedPlayerSpawn(ulong clientId, uint playerPrefabHash) | |||
NetworkMetrics.TrackObjectSpawnSent(clientPair.Key, ConnectedClients[clientId].PlayerObject, size); | |||
} | |||
} | |||
|
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.
Poor NetworkManager is so large already....could this live in its own file? Preferably in the Editor folder?
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.
I will see what I can do about removing the editor related code from NetworkManager into some other class within the NGO editor assembly.
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.
Ok, I see the update, but originally imagined like all this code from line 1705 to 1785 would be hoisted to NetworkManagerHelper.cs
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.
Looks good if we can hoist that new editor checking code into another file per my comment. Thoughts?
The pop-up warning logic doesn't scale in bigger projects. The version 1.0.0-pre.5 added this check for nested Please consider to remove / change it ! 🙏 |
@MARKED-ONE I only am suggesting something along those lines as a work around to prevent the editor only check for reparenting As a reminder, we have not tested NGO on all third party solutions/packages and with Zenject you could run into more complexities if using dependency injection with things like NetworkBehaviour derived components. NGO v1.x uses ILPP to build internal tables which provide maps to various things (i.e. RPCs, Network Serialization, NetworkVariables, etc) and methods which depending upon the order of operations of Zenject relative to NGO it could result in other complexities not accounted for in NGO v1.x versions. |
Hi @MARKED-ONE ! In our project, we call this method in our installer as a workaround to prevent the error :
Hope it can help you 😄 |
@NoelStephensUnity yes, my idea was to have a prefab with configured network setup, then simply spawn that prefab via Zenject and inject the NetworkManager wherever it is needed. I'm still new to Netcode, so only exploring what is the best way to pair it with Zenject. This problem just seemed like a potential bug to me. Also, I tried your workaround and can confirm that it works without issues. @WhippetsAintDogs clever solution! 😄I will probably choose this one as it doesn't require multiple prefabs. I personally was considering keeping everything as is because I can definitely live with the error in console, at least for now. But I really prefer 0 errors 0 warnings practice. And thank you both for the helpful tips! |
@WhippetsAintDogs |
…ty-Technologies#1484) * refactor This commit includes the removal of the DontDestroy property as well as the changes to detect when a NetworkManager is nested. * update Updating various places where the DontDestroy property was being used or tested. * changelog update Added the two changes made for NetworkManager. * refactor Migrated a large chunk of the editor specific code into the NGO editor assembly. * refactor Removing runtime GUI notification for nested NetworkManager since this will notify the user in the editor and development builds via the debug console. Added an additional editorTest parameter for in-editor unit test. * test Adding editor and runtime tests to verify this fix. * style removing white space. * fix Attempting to fix the failure on Mac for NetworkTransformRespawnTests
This addresses Github-Issue #1417 (described above) where users will now be provided notifications that the NetworkManager cannot be parented under another GameObject (nested). This PR also removes the DontDestroy property from the NetworkManager so that no NetworkManager instance can be destroyed by unloading a scene.
Development Standalone Build: The in-engine debug console displays the message that they cannot nest a NetworkManager
Editor Edit-Mode: A dialog box notifies the user that they cannot nest a NetworkManager and provides the option for the user to auto-fix or manually fix it
Editor Play-Mode: A dialog box just notifies the user that they cannot nest a NetworkManager
MTT-1732
PR Checklist
type:backport-release-*
label. After you backport the PR, the label changes tostat:backported-release-*
.CHANGELOG.md
file.Changelog
com.unity.netcode.gameobjects
Testing and Documentation