feat: Make INetworkStreamDriverConstructor useful #3501
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 PR addresses MTTB-1331 by making it simpler to use a custom driver constructor without breaking things.
INetworkStreamDriverConstructor
is a mechanism that was added a long time ago that allows users to override the creation of theNetworkDriver
thatUnityTransport
is using. As the name might hint at, it was pulled directly out of N4E and was never properly integrated intoUnityTransport
.For example, before this PR, a user implementing a custom driver constructor would need to recreate the settings and pipelines manually if they wanted to mimic the default behavior of
UnityTransport
, which required reading the code to figure out how we are settings things up. In the case of pipelines, it's not even possible to do that in all cases because one of the pipelines used when the multiplayer tools package is installed is internal.This PR addresses this by making both the default settings and default pipeline configurations available through the new
GetDefaultNetworkSettings
andGetDefaultPipelineConfigurations
methods. A user can use these methods to reuse or extend the configurationUnityTransport
uses by default. The (new and improved) documentation of the driver constructor interface provides an example of how to do so.As a bonus, this centralizes all the
NetworkSettings
in one place which makes the code a tiny bit more organized.Changelog
GetDefaultNetworkSettings
andGetDefaultPipelineConfigurations
toUnityTransport
. These can be used to retrieve the default settings and pipeline stages that are used byUnityTransport
. This is useful when providing a custom driver constructor throughUnityTransport.s_DriverConstructor
, since it allows reusing or tuning the existing configuration instead of trying to recreate it. This means a transport with a custom driver can now easily benefit from most of the features ofUnityTransport
, like integration with the Network Simulator and Network Profiler from the multiplayer tools package.Testing and Documentation
Backport
I don't plan on backporting this, unless the team feels strongly otherwise.