Network Settings
The configuration of the NetworkDriver
is defined using the NetworkSettings
API. It might be required to change some of the default values of the parameters, that can be done as in the following example.
#
Extending the NetworkSettingsWhen extending Unity Transport it is often useful to add custom parameters or settings that users can set to define the configuration of the NetworkDriver
.
That can be done by extending the NetworkSettings
API so the custom Network Interfaces or Pipelines can capture the parameter values inside the Initialization method as detailed in the following sections.
#
INetworkParameterBy implementing the INetworkParameter
interface, any unmanaged struct can be identified as a network parameter that can be assigned to the NetworkDriver
settings.
The NetworkSettings
will automatically call the Validate()
method and will throw an exception if false
is returned.
#
NetworkSettings extension methodsEvery new custom INetworkParameter
requires of at least one extension method to the NetworkSettings
API. These extension methods must receive and return a ref NetworkSettings
to ensure the proper functioning of the fluent interface.
Those constraints are checked by the Roslyn Analyzers provided in the Unity Transport package.