Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- `NetworkManager` will now perform a proper shutdown when the domain is reloaded in play mode, instead of being left in some half-initialized state that leaks memory and socket handles. (#4068)
- Issue where a NullReferenceException was thrown when a non-authority failed to spawn a NetworkObject. (#4067)
- Issue when FastBufferReader is attempting to read a string and all or a portion of the character count has already been read by user script, it could read a character length that results in a negative byte length which could result in an editor crash. (#4052)
- Issue where NetworkRigidbodyBase was not applying rotation correctly when using Rigidbody2D. (#4012)
Expand Down
17 changes: 17 additions & 0 deletions com.unity.netcode.gameobjects/Editor/NetworkManagerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ private static void InitializeOnload()
Singleton = new NetworkManagerHelper();

NetworkManager.NetworkManagerHelper = Singleton;

AssemblyReloadEvents.beforeAssemblyReload -= AssemblyReloadEvents_beforeAssemblyReload;
AssemblyReloadEvents.beforeAssemblyReload += AssemblyReloadEvents_beforeAssemblyReload;

EditorApplication.playModeStateChanged -= EditorApplication_playModeStateChanged;
EditorApplication.hierarchyChanged -= EditorApplication_hierarchyChanged;

Expand All @@ -55,6 +59,19 @@ private static void InitializeOnload()
};
}

private static void AssemblyReloadEvents_beforeAssemblyReload()
{
if (Application.isPlaying)
{
var networkManager = NetworkManager.Singleton;
if (networkManager != null && (networkManager.IsServer || networkManager.IsClient))
{
networkManager.Shutdown();
networkManager.ShutdownInternal();
}
}
}

private static void EditorApplication_playModeStateChanged(PlayModeStateChange playModeStateChange)
{
switch (playModeStateChange)
Expand Down