Commit f70eab1
feat: Make INetworkStreamDriverConstructor useful (#3501)
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.
---------
Co-authored-by: Noel Stephens <noel.stephens@unity3d.com>1 parent a06c9d8 commit f70eab1
File tree
4 files changed
+290
-213
lines changed- com.unity.netcode.gameobjects
- Runtime/Transports/UTP
4 files changed
+290
-213
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 79 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments