Skip to content

fix: Fixed CheckObjectVisibility delegate not being properly invoked for connecting clients when Scene Management is enabled. #1680

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
Merged
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 @@ -23,6 +23,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
- Fixed overloading RPC methods causing collisions and failing on IL2CPP targets. (#1694)
- Fixed spawn flow to propagate `IsSceneObject` down to children NetworkObjects, decouple implicit relationship between object spawning & `IsSceneObject` flag (#1685)
- Fixed error when serializing ConnectionApprovalMessage with scene management disabled when one or more objects is hidden via the CheckObjectVisibility delegate (#1720)
- Fixed CheckObjectVisibility delegate not being properly invoked for connecting clients when Scene Management is enabled. (#1680)

## [1.0.0-pre.5] - 2022-01-26

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,14 @@ internal void InitializeForSynch()

internal void AddSpawnedNetworkObjects()
{
m_NetworkObjectsSync = m_NetworkManager.SpawnManager.SpawnedObjectsList.ToList();
m_NetworkObjectsSync.Clear();
foreach (var sobj in m_NetworkManager.SpawnManager.SpawnedObjectsList)
{
if (sobj.Observers.Contains(TargetClientId))
{
m_NetworkObjectsSync.Add(sobj);
}
}
m_NetworkObjectsSync.Sort(SortNetworkObjects);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ internal void UpdateObservedNetworkObjects(ulong clientId)
{
foreach (var sobj in SpawnedObjectsList)
{
if (sobj.CheckObjectVisibility == null || NetworkManager.IsServer)
if (sobj.CheckObjectVisibility == null)
{
if (!sobj.Observers.Contains(clientId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TearDown()
}

[UnityTest]
public IEnumerator HiddenObjectsTest()
public IEnumerator HiddenObjectsTest([Values] bool enableSeneManagement)
{

const int numClients = 1;
Expand All @@ -37,11 +37,11 @@ public IEnumerator HiddenObjectsTest()
var validNetworkPrefab = new NetworkPrefab();
validNetworkPrefab.Prefab = m_TestNetworkPrefab;
server.NetworkConfig.NetworkPrefabs.Add(validNetworkPrefab);
server.NetworkConfig.EnableSceneManagement = false;
server.NetworkConfig.EnableSceneManagement = enableSeneManagement;
foreach (var client in clients)
{
client.NetworkConfig.NetworkPrefabs.Add(validNetworkPrefab);
client.NetworkConfig.EnableSceneManagement = false;
client.NetworkConfig.EnableSceneManagement = enableSeneManagement;
}

// Start the instances
Expand Down