Skip to content

Commit 10ba2ae

Browse files
fix: clarifying additive scene synchronization fix for reconnection flow [MTT-3450] (#864)
* clarify comments about where some scene events are executed * clarifying comments about fix for additive scenes when synchronizing
1 parent b13ad94 commit 10ba2ae

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Packages/com.unity.multiplayer.samples.coop/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Multiplayer Samples Co-op Changelog
22

3-
## [Unreleased]
3+
## [Unreleased] - yyyy-mm-dd
44

55
### Fixed
6+
* Clarified fix used to handle clients reconnecting to the server while keeping the same active scene and having additional scenes additively loaded (#864)
67
* Host loading progress bar is now properly updated on all clients during scene loads (#862)
78

89
## [1.6.1] - 2023-06-14

Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void OnSceneEvent(SceneEvent sceneEvent)
133133
switch (sceneEvent.SceneEventType)
134134
{
135135
case SceneEventType.Load: // Server told client to load a scene
136-
// Only executes on client
136+
// Only executes on client or host
137137
if (NetworkManager.IsClient)
138138
{
139139
// Only start a new loading screen if scene loaded in Single mode, else simply update
@@ -150,22 +150,29 @@ void OnSceneEvent(SceneEvent sceneEvent)
150150
}
151151
break;
152152
case SceneEventType.LoadEventCompleted: // Server told client that all clients finished loading a scene
153-
// Only executes on client
153+
// Only executes on client or host
154154
if (NetworkManager.IsClient)
155155
{
156156
m_ClientLoadingScreen.StopLoadingScreen();
157157
}
158158
break;
159159
case SceneEventType.Synchronize: // Server told client to start synchronizing scenes
160160
{
161-
// todo: this is a workaround that could be removed once MTT-3363 is done
162161
// Only executes on client that is not the host
163162
if (NetworkManager.IsClient && !NetworkManager.IsHost)
164163
{
165-
// unload all currently loaded additive scenes so that if we connect to a server with the same
166-
// main scene we properly load and synchronize all appropriate scenes without loading a scene
167-
// that is already loaded.
168-
UnloadAdditiveScenes();
164+
if (NetworkManager.SceneManager.ClientSynchronizationMode == LoadSceneMode.Single)
165+
{
166+
// If using the Single ClientSynchronizationMode, unload all currently loaded additive
167+
// scenes. In this case, we want the client to only keep the same scenes loaded as the
168+
// server. Netcode For GameObjects will automatically handle loading all the scenes that the
169+
// server has loaded to the client during the synchronization process. If the server's main
170+
// scene is different to the client's, it will start by loading that scene in single mode,
171+
// unloading every additively loaded scene in the process. However, if the server's main
172+
// scene is the same as the client's, it will not automatically unload additive scenes, so
173+
// we do it manually here.
174+
UnloadAdditiveScenes();
175+
}
169176
}
170177
break;
171178
}

0 commit comments

Comments
 (0)