Skip to content

Commit 9d9df2d

Browse files
authored
fix: Scene loading for CMB Service (#3469)
<!-- Replace this block with what this PR does and why. Describe what you'd like reviewers to know, how you applied the engineering principles, and any interesting tradeoffs made. Delete bullet points below that don't apply, and update the changelog section as appropriate. --> <!-- Add short version of the JIRA ticket to the PR title (e.g. "feat: new shiny feature [MTT-123]") --> [MTTB-1278](https://jira.unity3d.com/browse/MTTB-1273) ## Changelog - Fixed: #3458 stopped sending scene events directly to the CMB service. The CMB service uses those events for managing what objects exist. This PR puts back sending those messages. ## Testing and Documentation - Upgraded `InScenePlacedNetworkObjectTests` to work with the CMB Service <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> ## Backport <!-- If this is a backport: - Add the following to the PR title: "\[Backport\] ..." . - Link to the original PR. If this needs a backport - state this here If a backport is not needed please provide the reason why. If the "Backports" section is not present it will lead to a CI test failure. --> No backport needed, only a 2.0.0 change.
1 parent 05f2e3d commit 9d9df2d

File tree

2 files changed

+78
-56
lines changed

2 files changed

+78
-56
lines changed

com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,18 @@ private void SendSceneEventData(uint sceneEventId, ulong[] targetClientIds)
10711071
var sceneEvent = SceneEventDataStore[sceneEventId];
10721072
sceneEvent.SenderClientId = NetworkManager.LocalClientId;
10731073

1074+
// Send related message to the CMB service
1075+
if (NetworkManager.DistributedAuthorityMode && NetworkManager.CMBServiceConnection && HasSceneAuthority())
1076+
{
1077+
sceneEvent.TargetClientId = NetworkManager.ServerClientId;
1078+
var message = new SceneEventMessage
1079+
{
1080+
EventData = sceneEvent,
1081+
};
1082+
var size = NetworkManager.ConnectionManager.SendMessage(ref message, k_DeliveryType, NetworkManager.ServerClientId);
1083+
NetworkManager.NetworkMetrics.TrackSceneEventSent(NetworkManager.ServerClientId, (uint)sceneEvent.SceneEventType, SceneNameFromHash(sceneEvent.SceneHash), size);
1084+
}
1085+
10741086
// Send to each individual client to assure only the in-scene placed NetworkObjects being observed by the client
10751087
// is serialized
10761088
foreach (var clientId in targetClientIds)

0 commit comments

Comments
 (0)