feat: Make custom driver construction smoother#3980
Open
simon-lemay-unity wants to merge 3 commits into
Open
Conversation
EmandM
reviewed
May 12, 2026
| out NativeArray<NetworkPipelineStageId> reliableSequencedPipelineStages) | ||
| { | ||
| #if MULTIPLAYER_TOOLS_1_0_0_PRE_7 | ||
| driver.RegisterPipelineStage(new NetworkMetricsPipelineStage()); |
Member
There was a problem hiding this comment.
Would it make more sense for driver.RegisterPipelineStage to be defined with a conditional attribute?
[Conditional("MULTIPLAYER_TOOLS_1_0_0_PRE_7")]
void RegisterPipelineStage(NetworkMetricsPipelineStage pipelineStage)
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
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.
Purpose of this PR
Currently if you're using a custom driver constructor, you have to remember to register the metrics pipeline stage when the multiplayer tools package is installed. That can be a bit inconvenient since that pipeline stage is only defined when the tools package is installed, and also because it's not very intuitive that this needs doing.
This PR address that by:
NetworkMetricsPipelineStageregardless of the multiplayer tools package being installed or not. This way users can always register it and don't need to add a version define to guard its registration. Worst case they'll just register a pipeline stage that will go unused, which costs nothing.GetDefaultPipelineConfigurationsthat takes a reference to the newly-constructed driver and will do the registration itself, completely removing the need for users to know about this quirk.(The second change actually completely alleviates the need for the first, but I went ahead with both anyway just to make things easier on users no matter what API they're using to get the default pipeline configurations.)
Jira ticket
N/A
Changelog
UnityTransport.GetDefaultPipelineConfigurationsthat takes a reference to the createdNetworkDriver. This will register all pipeline stages thatUnityTransportrequires, removing the need to manually register them in your own custom driver constructor.NetworkMetricsPipelineStageis now defined even when the multiplayer tools package is not installed, removing the need to guard its registration behind a version define when using a custom driver inUnityTransport.Documentation
Testing & QA
Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by existing automated testsCovered by new automated testsDoes the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?Backports
N/A