-
Notifications
You must be signed in to change notification settings - Fork 450
feat: client scene synchronization mode #1171
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
feat: client scene synchronization mode #1171
Conversation
This allows for two different types of client synchronization modes (ClientSynchronizationMode): LoadSceneMode.Single: All currently loaded scenes on the client will be unloaded and the server's currently active scene will be loaded in single mode on the client unless it was already loaded. LoadSceneMode.Additive: All currently loaded scenes are left as they are and any newly loaded scenes will be loaded additively. Uses need to determine which scenes are valid to load via the VerifySceneBeforeLoading method.
Added the ability to squelch the validation warning messages for ClientSynchronizationMode additive as it will throw warnings for every loaded scene you don't want to have the client synchronize. Updated the comments.
/// scenes will be loaded additively. Users need to determine which scenes are valid to load via the | ||
/// <see cref="VerifySceneBeforeLoading"/> method. | ||
/// </summary> | ||
public LoadSceneMode ClientSynchronizationMode { get; internal set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests for Single & Additive to validate this works in both modes and gives us the results we expect on the client-side? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, for single mode it works already otherwise it wouldn't have passed the already existing tests.
I will add some additional passes in the existing tests which use additive ClientSynchronizationMode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to the scene loading tests. It now runs the tests with client synchronization set to both LoadSceneMode.Additive and LoadSceneMode.Single.
@@ -43,7 +43,7 @@ private class SceneTestInfo | |||
|
|||
|
|||
[UnityTest] | |||
public IEnumerator SceneLoadingAndNotifications() | |||
public IEnumerator SceneLoadingAndNotifications([Values(LoadSceneMode.Single,LoadSceneMode.Additive)] LoadSceneMode clientSynchronizationMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so how we verify whether single or additive modes result into single or additive on the client-side?
I'm not seeing any checks or asserts — does this mean that "works fine" implicitly means "unit-tested"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, will add verification that the SceneEventData on the client side reflects the clientSynchronization mode set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…nsform * develop: feat: NetworkBehaviour.IsSpawned (#1190) feat: added tip to the network manager inspector that directs to install tools (MTT-1211) (#1182) refactor!: remove network dictionary & set, use native container in List, add tests (#1149) fix: Fixed remote disconnects not properly cleaning up (#1184) test: base changes to PR-1114 (#1165) test: verify do not destroy networkobjects on networkmanager shutdown (#1183) chore: removal of EnableNetworkVariable in NetworkConfig. It's always True now (#1179) fix: Fix DontDestroyWithOwner not returning ownership (#1181) test: Giving Android some more room as the connection tests are timing sensitive (#1178) fix: unitytransport connectionmode buttons (#1176) test: added min frames to multi-instance helper (#1170) chore: Add mobile tests to nightly trigger (#1161) feat: snapshot spawn pre-requisite (#1166) feat: Unity Transport + Relay (#887) feat: client scene synchronization mode (#1171) # Conflicts: # testproject/Assets/Scenes/SampleScene.unity
* refactor This allows for two different types of client synchronization modes (ClientSynchronizationMode): LoadSceneMode.Single: All currently loaded scenes on the client will be unloaded and the server's currently active scene will be loaded in single mode on the client unless it was already loaded. LoadSceneMode.Additive: All currently loaded scenes are left as they are and any newly loaded scenes will be loaded additively. Uses need to determine which scenes are valid to load via the VerifySceneBeforeLoading method. * refactor and style Added the ability to squelch the validation warning messages for ClientSynchronizationMode additive as it will throw warnings for every loaded scene you don't want to have the client synchronize. Updated the comments. * style fixing spelling typo. * test added Values to the scene loading test that will run the scene loading tests with client synchronization set to both LoadSceneMode.Single and LoadSceneMode.Additive. * test Adding verification that the client synchronization mode used by the server when building the client synchronization SceneEventData message is the same value on the client side. * style fixing whitespace issue
This is a very minor tweak to how clients are synchronized in order to support two different styles of scene loading during client synchronization. There is a new method, NetworkSceneManager.SetClientSynchronizationMode, that provides users with the ability to configure this feature.
When the ClientSynchronizationMode is set to LoadSceneMode.Single:
If the server's currently active scene is not already loaded on the client then it will be loaded in single mode. This means that all currently loaded scenes on the client will be unloaded.
When the ClientSynchronizationMode is set to LoadSceneMode.Additive:
All currently loaded scenes are left as they are on the client and any newly loaded scenes will be loaded additively. Users control which scenes are valid for the server to instruct the client to load via the method.
This update also includes the ability to squelch the VerifySceneBeforeLoading console messages which would commonly be used when ClientSynchronizationMode is set to LoadSceneMode.Additive.
The default ClientSynchronizationMode is LoadSceneMode.Single which behaves like the traditional MLAPI initial client synchronization loading pattern.