Skip to content

feat: Make custom driver construction smoother#3980

Open
simon-lemay-unity wants to merge 3 commits into
develop-2.0.0from
feat/simplify-custom-interfaces
Open

feat: Make custom driver construction smoother#3980
simon-lemay-unity wants to merge 3 commits into
develop-2.0.0from
feat/simplify-custom-interfaces

Conversation

@simon-lemay-unity
Copy link
Copy Markdown
Contributor

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:

  • Always defining NetworkMetricsPipelineStage regardless 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.
  • Adding a new variant of GetDefaultPipelineConfigurations that 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

  • Added: Added a new variant of UnityTransport.GetDefaultPipelineConfigurations that takes a reference to the created NetworkDriver. This will register all pipeline stages that UnityTransport requires, removing the need to manually register them in your own custom driver constructor.
  • Changed: NetworkMetricsPipelineStage is 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 in UnityTransport.

Documentation

  • Includes edits to existing public API documentation.

Testing & QA

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

Backports

N/A

@simon-lemay-unity simon-lemay-unity requested review from a team as code owners May 12, 2026 16:05
out NativeArray<NetworkPipelineStageId> reliableSequencedPipelineStages)
{
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
driver.RegisterPipelineStage(new NetworkMetricsPipelineStage());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Member

@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.

I love a simplification!

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.

2 participants