Skip to content

Commit b2f013a

Browse files
Merge branch 'develop' into fix/replace-null-coalescence-operators
2 parents 75977cc + 10ba2ae commit b2f013a

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Replaced usages of null-coalescing and null-conditional operators with regular null checks. (#867) These operators can cause issues when used with types inheriting UnityEngine.Object because that type redefines the == operator to define when an object is null. This redefinition applies to regular null checks (if foo == null) but not to those operators, thus this could lead to unexpected behaviour. While those operators were safely used within Boss Room, only with types that were not inheriting UnityEngine.Object, we decided to remove most usages for consistency. This will also help avoid accidental mistakes, such as a user reusing a part of this code, but modifying it so that one of those operators are used with a UnityEngine.Object.
77

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

1112
## [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)