Skip to content

feat: Make INetworkStreamDriverConstructor useful #3501

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

Merged
merged 8 commits into from
Jul 10, 2025

Conversation

simon-lemay-unity
Copy link
Contributor

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 the NetworkDriver that UnityTransport is using. As the name might hint at, it was pulled directly out of N4E and was never properly integrated into UnityTransport.

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 and GetDefaultPipelineConfigurations methods. A user can use these methods to reuse or extend the configuration UnityTransport 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

  • Added: Added methods GetDefaultNetworkSettings and GetDefaultPipelineConfigurations to UnityTransport. These can be used to retrieve the default settings and pipeline stages that are used by UnityTransport. This is useful when providing a custom driver constructor through UnityTransport.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 of UnityTransport, like integration with the Network Simulator and Network Profiler from the multiplayer tools package.

Testing and Documentation

  • No tests have been added.
  • Includes edits to existing public API documentation.

Backport

I don't plan on backporting this, unless the team feels strongly otherwise.

@simon-lemay-unity simon-lemay-unity requested a review from a team as a code owner June 13, 2025 18:28
Copy link
Collaborator

@EmandM EmandM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fantastic refactor!

@NoelStephensUnity
Copy link
Collaborator

Running manual tests at this time.

Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well.
Ran several manual test

@NoelStephensUnity NoelStephensUnity merged commit f70eab1 into develop-2.0.0 Jul 10, 2025
36 checks passed
@NoelStephensUnity NoelStephensUnity deleted the feat/useful-custom-drivers branch July 10, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants