-
Notifications
You must be signed in to change notification settings - Fork 450
test: additive scene loading #1030
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adjusting scene related commands. Keeping the original commands in place, but providing two new commands: SCENE_EVENT: This will contain sub-commands and additional information specific to the command. SCENE_NOTIFICATION: This is more for providing a mechanism to send various notifications (i.e. scene switch complete, scene loaded, scene unloaded, errors, etc) with the ability to include additional information about the event.
Added new SCENE_EVENT that will handle "all things scene relative" with the only exception of the approval process. That will need to be handled in a different PR as that requires a bunch of additional changes. Focus for this branch is to get additive scene loading and unloading working.
Added additive scene unloading into the mix. Currently no events are wired for additive loading complete or additive unloading complete, but console logging on the server side verifies that the client sends the appropriate scene event notification once finished loading or unloading. Cleaned up some of the test project code to make sure the client isn't creating a pool to make sure the client is only replicating what the server is telling it to as well as various other minor test project tweaks for additive scene loading demonstration purposes.
Removed static properties in NetworkSceneManager that were no longer being used. Fixed issue with host not having the proper network prefab override (i.e. running as host vs running as server). Moved SceneEventData into its own .cs file. Excluding the local notification events, this is very close to being finalized, with the exception of custom prefab overrides and additive scene loading. This still has issues with late joining (most likely this has to do with the NetworkPrefabPool code base, still investigating this issue).
Improved the NetworkPrefabPool and NetworkPrefabPoolAdditive implementations to properly handle the various potential use case scenarios. These changes assure that both the client and the server leverage from the pool. This also takes into account NetworkManager defined NetworkPrefab overrides. Added temporary LoadSceneEvent callback that notifies if an additive scene is being loaded or unloaded. Updated the NetworkPrefabPoolAdditive sample to demonstrate how a user can assure their NetworkObjects are "spawned" in the same additive scene as their spawn generator. This pattern will always destroy all NetworkObjects if the additive scene is unloaded. Added sorting of NetworkObjects just prior to the server side serializing them in order to assure INetworkPrefabInstanceHandler implementations are registered first, this is required in order to assure that the handler is registered before any NetworkObjects associated with it are spawned.
Some temporary fixes for message ordering and buffering during late-join until this gets merged with the message ordering updates and we add the ability to buffer messages while a player is late-joining. Primarily in the GenericNetworkObjectBehaviour class. Added a proposed solution to handle order of operations if user decides to allow all NetworkObjects from a prefab pool to be spawned in the active scene. This requires the ability to separate NetworkObjects (server side) by associated scene so that they will be synchronized properly with their spawn generator's pool. Now tracking which additive scenes have been loaded to be assured they are unloaded when doing a full scene switch (i.e. singlemode loading), otherwise there can be issues that arise with currently loaded additive scenes.
Two issues were discovered while getting the parenting test working: 1.) t was doing a move objects to scene during the client side synchronization process (which doesn't need to happen) and as such was setting all parents to null which was throwing an exception. 2.) The server side wasn't filtering out any pre-loaded scenes during the synchronization process.
Minor test project fixes and additional tests for the AdditiveSceneToggleHandler to test back to back scene loading during a scene transition. Removed the distinguishing difference between switchscene and loadscene, left the switchscene as a wrapper around loadscene. Updated existing profiling code base to remove legacy scene manager profiler checks.
This resolves the issue where disabling scene management would result in no NetworkObjectSynchronization of client relative observed NetworkObjects. This also further separates NetworkObject serialization even further from the NetworkSceneManager and is contained either in: NetworkSpawnManager, SceneEventData, and NetworkObject itself. This will help in future efforts to further unify this process with some form of "NetworkObjectSynchronization" system that ties together NetworkSceneManager, Snapshot, and NetworkSpawnManager related client/server NetworkObject synchronization/registration related tasks into a single management system that should work independently of other systems (at least something in that general direction).
------------------------------------------------------------- After further consideration, the best idea for the whole unit test issue is to: 1.) Not try to detect it ( silly idea of mine ) 2,) Make changes to the NetworkSceneManager's private m_ScenesLoaded property by renaming it to ScenesLoaded and making it internal. 3.) Update the one Unit test that was failing to populate ScenesLoaded and ServerSceneHandleToClientSceneHandle tables so the SetTheSceneBeingSynchronized method could properly be tested during the NetworkObjectSceneSerializationFailure test. It turns out my brain decided to take a "(dis)connect" day a few days too early. No need to check for unit tests at all for this PR. ------------------------------------------------------------- This also includes a minor adjustment for when the NetworkPrefabPool (test project script) unsubscribes from the NetworkSceneManager.OnSceneEvent to avoid a null access exception.
Took Fatih's suggestion regarding ScenesLoaded being over-complicated and now the ScenesLoaded is just a dictionary of scene handle keys and each key entry value is the Scene it is associated with. This did reduce some of the complexity in the unloading methods and the GetAndAddNewlyLoadedSceneByName method. Updated the NetworkObjectSceneSerializationFailure unit test to reflect the above changes.
…g' into test/AdditiveSceneLoading
Noticed one minor portion of the client loading process that really shouldn't be outside of SceneEventData. Removed 1 method call from NetworkSceneManager and 1 method from SceneEventData.
In order to validate scene loading for (n) clients and a server/host, I did add an automated way to check if a unit test is running (for now) in order to assure clients don't try to load a single mode scene. Also merged the recent changes to the feat/MTT-820-AdditiveSceneLoading branch, and made some adjustments to those changes in NetworkSceneManagerTests.
Added the suggested || DEVELOPMENT_BUILD to the unit test check and adjusted the 3 locations to mirror this addition. As well, added comments to explain why we are doing this here.
andrews-unity
approved these changes
Aug 23, 2021
closed in favor of PR #1076 |
NoelStephensUnity
added a commit
that referenced
this pull request
Aug 23, 2021
* redo #1030 * comment a todo for `m_IsRunningUnitTest` * test project Adding check for unit testing at the end of OnClientUnloadScene to determine if we need to just passthrough to the callback (for multiInstance unit testing only) Fixing minor issue with NetworkObject not being around after unloading a scene for NetworkPrefabPool. Co-authored-by: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
mollstam
pushed a commit
to Keepsake-Games/com.unity.netcode.gameobjects
that referenced
this pull request
Feb 13, 2023
…hnologies#1076) * redo Unity-Technologies#1030 * comment a todo for `m_IsRunningUnitTest` * test project Adding check for unit testing at the end of OnClientUnloadScene to determine if we need to just passthrough to the callback (for multiInstance unit testing only) Fixing minor issue with NetworkObject not being around after unloading a scene for NetworkPrefabPool. Co-authored-by: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the test for PR-955 --> Please Review that first. :)
(this will be much easier to review once PR-955 is merged)
This includes the unit testing for additive scene loading using multi-instances.
It includes a minor adjustment to NetworkSceneManager to handle unit testing with multi-instances.
This removes the legacy Runtime NetworkSceneManagerTest and migrates the check for assert when EnableSceneManagement is set to false into the new NetworkSceneManagerTests.
Current Tests: