-
Notifications
You must be signed in to change notification settings - Fork 459
fix: networklog can throw exception when no networkmanager exists #3917
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
Merged
NoelStephensUnity
merged 8 commits into
develop-2.0.0
from
fix/networklog-can-throw-exception-when-no-networkmanager-exists
Mar 30, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eab178e
fix
NoelStephensUnity 5ac4ef6
test
NoelStephensUnity 668c212
update
NoelStephensUnity 2dac37c
style
NoelStephensUnity 3939f31
fix
NoelStephensUnity c3cd512
Merge develop-2.0.0 into fix/networklog-can-throw-exception-when-no-n…
netcode-ci-service 6bf96fa
Merge develop-2.0.0 into fix/networklog-can-throw-exception-when-no-n…
netcode-ci-service 68d7d06
Merge develop-2.0.0 into fix/networklog-can-throw-exception-when-no-n…
netcode-ci-service File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
com.unity.netcode.gameobjects/Tests/Runtime/NetworkLogTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| using System.Collections; | ||
| using Unity.Netcode.TestHelpers.Runtime; | ||
| using UnityEngine.TestTools; | ||
|
|
||
| namespace Unity.Netcode.RuntimeTests | ||
| { | ||
| /// <summary> | ||
| /// Validates edge cases with <see cref="NetworkLog"/> | ||
| /// </summary> | ||
| internal class NetworkLogTests : NetcodeIntegrationTest | ||
| { | ||
| protected override int NumberOfClients => 0; | ||
| private bool m_ServerStopped; | ||
|
|
||
| /// <summary> | ||
| /// Validates that if no <see cref="NetworkManager"/> exists, | ||
| /// you can still use NetworkLog with the caveat when one does | ||
| /// not exist it will only log locally. | ||
| /// (is topology agnostic) | ||
| /// </summary> | ||
| [UnityTest] | ||
| public IEnumerator UseNetworkLogWithNoNetworkManager() | ||
| { | ||
| m_ServerStopped = false; | ||
| var authority = GetAuthorityNetworkManager(); | ||
| authority.OnServerStopped += OnServerStopped; | ||
| authority.Shutdown(); | ||
| yield return WaitForConditionOrTimeOut(() => m_ServerStopped); | ||
| AssertOnTimeout($"Timed out waiting for {nameof(NetworkManager)} to stop!"); | ||
| // Assure it is destroyed. | ||
| UnityEngine.Object.Destroy(authority); | ||
| authority = null; | ||
|
|
||
| // Clear out the singleton to assure NetworkLog has no references to a NetworkManager | ||
| NetworkManager.ResetSingleton(); | ||
|
|
||
| // Validate you can use NetworkLog without any NetworkManager instance. | ||
| NetworkLog.LogInfoServer($"Test a message to the server with no {nameof(NetworkManager)}."); | ||
| // No exceptions thrown is considered passing. | ||
| } | ||
|
|
||
| private void OnServerStopped(bool obj) | ||
| { | ||
| m_ServerStopped = true; | ||
| } | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
com.unity.netcode.gameobjects/Tests/Runtime/NetworkLogTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.