Skip to content

Commit a5ad2af

Browse files
fix: host NetworkManager.LocalClient not being set (#1511)
* fix Fixes the issue with the host not having a NetworkManager.LocalClient assigned after starting. * test The test to validate the fix * updated changelog
1 parent 3e36a47 commit a5ad2af

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
3535
- Fixed: Fixed error when serializing ConnectionApprovalMessage with scene management disabled when one or more objects is hidden via the CheckObjectVisibility delegate (#1509)
3636
- Fixed KeyNotFound exception when removing ownership of a newly spawned NetworkObject that is already owned by the server. (#1500)
3737
- Fixed issue where pooled NetworkObjects using NetworkTransform would interpolate from their last de-spawned position to the newly spawned position (#1505)
38+
- Fixed NetworkManager.LocalClient not being set when starting as a host. (#1511)
3839

3940
### Changed
4041

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,7 @@ internal void HandleApproval(ulong ownerClientId, bool createPlayerObject, uint?
16731673
}
16741674
else // Server just adds itself as an observer to all spawned NetworkObjects
16751675
{
1676+
LocalClient = client;
16761677
SpawnManager.UpdateObservedNetworkObjects(ownerClientId);
16771678
InvokeOnClientConnectedCallback(ownerClientId);
16781679
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using NUnit.Framework;
2+
using Unity.Netcode.RuntimeTests;
3+
4+
namespace TestProject.RuntimeTests
5+
{
6+
public class NetworkManagerTests : BaseMultiInstanceTest
7+
{
8+
protected override int NbClients => 1;
9+
10+
[Test]
11+
public void ValidateHostLocalClient()
12+
{
13+
Assert.IsTrue(m_ServerNetworkManager.LocalClient != null);
14+
}
15+
}
16+
}

testproject/Assets/Tests/Runtime/NetworkManagerTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)