Skip to content

Commit

Permalink
fix: Stop checking hierarchy changed in playmode (#3026)
Browse files Browse the repository at this point in the history
* fix

stop checking for hierarchy changes when we enter into play mode.

* update

adding changelog entry

* style

fixing spelling mistake.

* update

adding PR number to changelog entry.
  • Loading branch information
NoelStephensUnity authored Aug 26, 2024
1 parent 1b900a4 commit 61a2d0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- Fixed issue where the `NetworkManagerHelper` was continuing to check for hierarchy changes when in play mode. (#3026)

### Changed

## [2.0.0-pre.4] - 2024-08-21
Expand Down
12 changes: 12 additions & 0 deletions com.unity.netcode.gameobjects/Editor/NetworkManagerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ private static void EditorApplication_playModeStateChanged(PlayModeStateChange p
{
s_LastKnownNetworkManagerParents.Clear();
ScenesInBuildActiveSceneCheck();
EditorApplication.hierarchyChanged -= EditorApplication_hierarchyChanged;
break;
}
case PlayModeStateChange.EnteredEditMode:
{
EditorApplication.hierarchyChanged += EditorApplication_hierarchyChanged;
break;
}
}
Expand Down Expand Up @@ -110,6 +116,12 @@ private static void ScenesInBuildActiveSceneCheck()
/// </summary>
private static void EditorApplication_hierarchyChanged()
{
if (Application.isPlaying)
{
EditorApplication.hierarchyChanged -= EditorApplication_hierarchyChanged;
return;
}

var allNetworkManagers = Resources.FindObjectsOfTypeAll<NetworkManager>();
foreach (var networkManager in allNetworkManagers)
{
Expand Down

0 comments on commit 61a2d0d

Please sign in to comment.