Skip to content

Commit 8b01cbe

Browse files
jeffreyrainy0xFA11
andauthored
fix: applying CheckObjectVisibility upon NetworkShow (#2463)
* fix: applying CheckObjectVisibility upon NetworkShow * making the log warning more visible * Update com.unity.netcode.gameobjects/CHANGELOG.md Co-authored-by: Fatih Mar <mfatihmar@gmail.com> --------- Co-authored-by: Fatih Mar <mfatihmar@gmail.com>
1 parent 5cfc157 commit 8b01cbe

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-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
- Changed `NetworkTransform` interpolation adjusts its interpolation "ticks ago" to be 2 ticks latent if it is owner authoritative and the instance is not the server or 1 tick latent if the instance is the server and/or is server authoritative. (#2388)
3636
- Updated `NetworkSceneManager` to migrate dynamically spawned `NetworkObject`s with `DestroyWithScene` set to false into the active scene if their current scene is unloaded. (#2383)
3737
- Updated the server to synchronize its local `NetworkSceneManager.ClientSynchronizationMode` during the initial client synchronization. (#2383)
38+
- Made sure the `CheckObjectVisibility` delegate is checked and applied, upon `NetworkShow` attempt. Found while supporting (#2454), although this is not a fix for this (already fixed) issue. (#2463)
3839

3940
### Fixed
4041

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ public void NetworkShow(ulong clientId)
331331
throw new VisibilityChangeException("The object is already visible");
332332
}
333333

334+
if (CheckObjectVisibility != null && !CheckObjectVisibility(clientId))
335+
{
336+
if (NetworkManager.LogLevel <= LogLevel.Normal)
337+
{
338+
NetworkLog.LogWarning($"[NetworkShow] Trying to make {nameof(NetworkObject)} {gameObject.name} visible to client ({clientId}) but {nameof(CheckObjectVisibility)} returned false!");
339+
}
340+
return;
341+
}
342+
334343
NetworkManager.MarkObjectForShowingTo(this, clientId);
335344
Observers.Add(clientId);
336345
}

0 commit comments

Comments
 (0)