refactor: add [RequireComponent(typeof(NetworkManager))] to NetworkAuthenticator#4116
Conversation
…r to NetworkManager NetworkManager owns the authenticator reference, so it should own the wiring logic. This removes the backwards dependency where NetworkAuthenticator needed to know about NetworkManager.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4116 +/- ##
=======================================
Coverage 42.19% 42.19%
=======================================
Files 156 156
Lines 15092 15092
=======================================
Hits 6368 6368
Misses 8724 8724
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@copilot NetworkAuthenticator doesn't work without NetworkManager. It should have |
…thenticator Reverts the Reset() move — Unity calls Reset() on the component being added, not on siblings, so NetworkManager.Reset() wouldn't fire when adding an authenticator. Instead, makes the dependency explicit with RequireComponent and keeps the existing auto-assignment in NetworkAuthenticator.Reset().
Good catch — Unity calls Reverted the move and added |
|
@copilot remove authenticator reset modifying networkmanager. instead networkmanager.awake can check if authenticator==null and getcomponent, then auto assign it |
Remove Reset() from NetworkAuthenticator — it no longer modifies NetworkManager. Instead, NetworkManager.Awake() auto-assigns the authenticator via GetComponent if authenticator is null.
Done in |
|
@copilot nvm only do the requirecomponent thing, nothing else |
…orkAuthenticator Reverts all other changes. The only modification is the RequireComponent attribute on the NetworkAuthenticator base class.
Reverted everything else in |
NetworkAuthenticatordoesn't work withoutNetworkManager, but the dependency was never declared explicitly.Changes
NetworkAuthenticator.cs: Added[RequireComponent(typeof(NetworkManager))]to the base class, making the dependency explicit at the Unity level.No change in user-facing behavior — Unity will auto-add a
NetworkManagerif one isn't present when adding an authenticator.