diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md
index 51fe4a90f6..19fdee6f0a 100644
--- a/com.unity.netcode.gameobjects/CHANGELOG.md
+++ b/com.unity.netcode.gameobjects/CHANGELOG.md
@@ -10,6 +10,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
### 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. (#3501)
### Fixed
diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs
new file mode 100644
index 0000000000..93203fec03
--- /dev/null
+++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs
@@ -0,0 +1,79 @@
+using Unity.Networking.Transport;
+
+namespace Unity.Netcode.Transports.UTP
+{
+ ///
+ ///
+ /// This interface allows one to override the creation of the object
+ /// that will be used under the hood by . This can be useful when
+ /// implementing a custom or to add custom pipeline stages to
+ /// the default pipelines.
+ ///
+ ///
+ /// To use a custom driver constructor, set to
+ /// an instance of an implementation of this interface. This must be done before calling
+ /// or .
+ ///
+ ///
+ ///
+ ///
+ /// This example implements a custom driver constructor that uses the IPC network interface from
+ /// the Unity Transport package. This network interface is used for intra-process communications
+ /// which can be useful for implementing a single-player version of a game. Since the example is
+ /// also preserving all the default settings and pipelines, you'd also benefit from all the
+ /// existing features of the transport, like integration with the Network Profiler.
+ ///
+ ///
+ /// public class IPCDriverConstructor : INetworkStreamDriverConstructor
+ /// {
+ /// public void CreateDriver(
+ /// UnityTransport transport,
+ /// out NetworkDriver driver,
+ /// out NetworkPipeline unreliableFragmentedPipeline,
+ /// out NetworkPipeline unreliableSequencedFragmentedPipeline,
+ /// out NetworkPipeline reliableSequencedPipeline)
+ /// {
+ /// var settings = transport.GetDefaultNetworkSettings();
+ /// driver = NetworkDriver.Create(new IPCNetworkInterface(), settings);
+ ///
+ /// transport.GetDefaultPipelineConfigurations(
+ /// out var unreliableFragmentedPipelineStages,
+ /// out var unreliableSequencedFragmentedPipelineStages,
+ /// out var reliableSequencedPipelineStages);
+ ///
+ /// unreliableFragmentedPipeline = driver.CreatePipeline(unreliableFragmentedPipelineStages);
+ /// unreliableSequencedFragmentedPipeline = driver.CreatePipeline(unreliableSequencedFragmentedPipelineStages);
+ /// reliableSequencedPipeline = driver.CreatePipeline(reliableSequencedPipelineStages);
+ /// }
+ /// }
+ ///
+ ///
+ public interface INetworkStreamDriverConstructor
+ {
+ ///
+ /// Creates the instance to be used by the transport.
+ ///
+ /// The transport for which the driver is created.
+ /// The newly-created .
+ ///
+ /// The driver's pipeline on which to send unreliable traffic. This pipeline must also
+ /// support fragmentation (payloads larger than the MTU).
+ ///
+ ///
+ /// The driver's pipeline on which to send unreliable but sequenced traffic. Traffic sent
+ /// on this pipeline must be delivered in the right order, although packet loss is okay.
+ /// This pipeline must also support fragmentation (payloads larger than the MTU).
+ ///
+ ///
+ /// The driver's pipeline on which to send reliable traffic. This pipeline must ensure that
+ /// all of its traffic is delivered, and in the correct order too. There is no need for that
+ /// pipeline to support fragmentation ( will handle that).
+ ///
+ void CreateDriver(
+ UnityTransport transport,
+ out NetworkDriver driver,
+ out NetworkPipeline unreliableFragmentedPipeline,
+ out NetworkPipeline unreliableSequencedFragmentedPipeline,
+ out NetworkPipeline reliableSequencedPipeline);
+ }
+}
diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs.meta b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs.meta
new file mode 100644
index 0000000000..959e44cbdb
--- /dev/null
+++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: cb3c2e99b33d54b4c9507e9550fb1603
\ No newline at end of file
diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
index 31b20b6630..6f9346b4b0 100644
--- a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
@@ -26,27 +26,6 @@
namespace Unity.Netcode.Transports.UTP
{
- ///
- /// Provides an interface that overrides the ability to create your own drivers and pipelines
- ///
- public interface INetworkStreamDriverConstructor
- {
- ///
- /// Creates the internal NetworkDriver
- ///
- /// The owner transport
- /// The driver
- /// The UnreliableFragmented NetworkPipeline
- /// The UnreliableSequencedFragmented NetworkPipeline
- /// The ReliableSequenced NetworkPipeline
- void CreateDriver(
- UnityTransport transport,
- out NetworkDriver driver,
- out NetworkPipeline unreliableFragmentedPipeline,
- out NetworkPipeline unreliableSequencedFragmentedPipeline,
- out NetworkPipeline reliableSequencedPipeline);
- }
-
///
/// The Netcode for GameObjects NetworkTransport for UnityTransport.
/// Note: This is highly recommended to use over UNet.
@@ -92,15 +71,19 @@ public enum ProtocolType
private static ConnectionAddressData s_DefaultConnectionAddressData = new ConnectionAddressData { Address = "127.0.0.1", Port = 7777, ServerListenAddress = string.Empty };
#pragma warning disable IDE1006 // Naming Styles
-
///
- /// The global implementation
+ /// An instance of a implementation. If null,
+ /// the default driver constructor will be used. Setting it to a non-null value allows
+ /// controlling how the internal instance is created. See the
+ /// interface's documentation for details.
///
public static INetworkStreamDriverConstructor s_DriverConstructor;
#pragma warning restore IDE1006 // Naming Styles
///
- /// Returns either the global implementation or the current instance
+ /// If a custom implementation is in use (see
+ /// ), this returns it. Otherwise it returns the current
+ /// instance, which acts as the default constructor.
///
public INetworkStreamDriverConstructor DriverConstructor => s_DriverConstructor ?? this;
@@ -422,7 +405,6 @@ public NetworkEndpoint GetLocalEndpoint()
private PacketLossCache m_PacketLossCache = new PacketLossCache();
- private NetworkSettings m_NetworkSettings;
private ulong m_ServerClientId;
private NetworkPipeline m_UnreliableFragmentedPipeline;
@@ -477,8 +459,6 @@ private void DisposeInternals()
m_Driver.Dispose();
}
- m_NetworkSettings.Dispose();
-
foreach (var queue in m_SendQueue.Values)
{
queue.Dispose();
@@ -489,6 +469,178 @@ private void DisposeInternals()
TransportDisposed?.Invoke(GetInstanceID());
}
+ ///
+ /// Get the that will be used to create the underlying
+ /// based on the current configuration of the transport. This
+ /// method is meant to be used with custom
+ /// implementations, where it can be used to modify the default parameters instead of
+ /// attempting to recreate them from scratch, which could be error-prone.
+ ///
+ ///
+ /// The returned object is allocated using the allocator.
+ /// Do not hold a reference to it for longer than the current frame.
+ ///
+ /// The default network settings.
+ ///
+ /// If the transport has an invalid configuration that prevents creating appropriate
+ /// settings for the driver. For example, if encryption is enabled but secrets haven't
+ /// been set, or if Relay is selected but the Relay server data hasn't been set.
+ ///
+ public NetworkSettings GetDefaultNetworkSettings()
+ {
+ var settings = new NetworkSettings();
+
+ // Basic driver configuration settings.
+ settings.WithNetworkConfigParameters(
+ maxConnectAttempts: m_MaxConnectAttempts,
+ connectTimeoutMS: m_ConnectTimeoutMS,
+ disconnectTimeoutMS: m_DisconnectTimeoutMS,
+ sendQueueCapacity: m_MaxPacketQueueSize,
+ receiveQueueCapacity: m_MaxPacketQueueSize,
+ heartbeatTimeoutMS: m_HeartbeatTimeoutMS);
+
+ // Configure Relay if in use.
+ if (m_ProtocolType == ProtocolType.RelayUnityTransport)
+ {
+ if (m_RelayServerData.Equals(default(RelayServerData)))
+ {
+ throw new Exception("You must call SetRelayServerData() before calling StartClient() or StartServer().");
+ }
+ else
+ {
+ settings.WithRelayParameters(ref m_RelayServerData, m_HeartbeatTimeoutMS);
+ }
+ }
+
+#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
+ // Latency, jitter and packet loss will be set by the network simulator in the tools
+ // package. We just need to initialize the settings since otherwise these features will
+ // not be enabled at all in the driver.
+ settings.WithSimulatorStageParameters(
+ maxPacketCount: 300, // TODO Is there any way to compute a better value?
+ randomSeed: DebugSimulatorRandomSeed ?? (uint)System.Diagnostics.Stopwatch.GetTimestamp());
+ settings.WithNetworkSimulatorParameters();
+#endif
+
+ // If the user sends a message of exactly m_MaxPayloadSize in length, we need to
+ // account for the overhead of its length when we store it in the send queue.
+ var fragmentationCapacity = m_MaxPayloadSize + BatchedSendQueue.PerMessageOverhead;
+ settings.WithFragmentationStageParameters(payloadCapacity: fragmentationCapacity);
+
+ // Bump the reliable window size to its maximum size of 64. Since NGO makes heavy use of
+ // reliable delivery, we're better off with the increased window size compared to the
+ // extra 4 bytes of header that this costs us.
+ //
+ // We also increase the maximum resend timeout since the default one in UTP is very
+ // aggressive (optimized for latency and low bandwidth). With NGO, it's too low and
+ // we sometimes notice a lot of useless resends, especially if using Relay.
+ var maxResendTime = m_ProtocolType == ProtocolType.RelayUnityTransport ? 750 : 500;
+ settings.WithReliableStageParameters(windowSize: 64, maximumResendTime: maxResendTime);
+
+ // Set up encryption if in use. This only needs to be done when not using Relay. If
+ // using Relay, then UTP configures encryption on its own based solely on the protocol
+ // configured in the Relay server data.
+ if (m_UseEncryption && m_ProtocolType == ProtocolType.UnityTransport)
+ {
+ if (m_NetworkManager.IsServer)
+ {
+ if (string.IsNullOrEmpty(m_ServerCertificate) || string.IsNullOrEmpty(m_ServerPrivateKey))
+ {
+ throw new Exception("In order to use encryption, you must call SetServerSecrets() before calling StartServer().");
+ }
+ else
+ {
+ settings.WithSecureServerParameters(m_ServerCertificate, m_ServerPrivateKey);
+ }
+ }
+ else
+ {
+ if (string.IsNullOrEmpty(m_ServerCommonName))
+ {
+ throw new Exception("In order to use encryption, you must call SetClientSecrets() before calling StartClient().");
+ }
+ else
+ {
+ if (string.IsNullOrEmpty(m_ClientCaCertificate))
+ {
+ settings.WithSecureClientParameters(m_ServerCommonName);
+ }
+ else
+ {
+ settings.WithSecureClientParameters(m_ClientCaCertificate, m_ServerCommonName);
+ }
+ }
+ }
+ }
+
+ return settings;
+ }
+
+ ///
+ /// Get the pipeline configurations that will be used based on the current configuration of
+ /// the transport. Useful for custom
+ /// implementations, since it allows extending the existing configuration while maintaining
+ /// the existing functionality of the default pipelines that's not otherwise available
+ /// publicly (like integration with the network profiler).
+ ///
+ ///
+ /// All returned values are allocated with the allocator. Do not
+ /// hold references to them longer than the current frame. There is no need to dispose of the
+ /// returned lists.
+ ///
+ ///
+ /// Pipeline stages that will be used for the unreliable and fragmented pipeline.
+ ///
+ ///
+ /// Pipeline stages that will be used for the unreliable, sequenced, and fragmented pipeline.
+ ///
+ ///
+ /// Pipeline stages that will be used for the reliable and sequenced pipeline stage.
+ ///
+ public void GetDefaultPipelineConfigurations(
+ out NativeArray unreliableFragmentedPipelineStages,
+ out NativeArray unreliableSequencedFragmentedPipelineStages,
+ out NativeArray reliableSequencedPipelineStages)
+ {
+ var unreliableFragmented = new NetworkPipelineStageId[]
+ {
+ NetworkPipelineStageId.Get(),
+#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
+ NetworkPipelineStageId.Get(),
+#endif
+#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
+ NetworkPipelineStageId.Get(),
+#endif
+ };
+
+ var unreliableSequencedFragmented = new NetworkPipelineStageId[]
+ {
+ NetworkPipelineStageId.Get(),
+ NetworkPipelineStageId.Get(),
+#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
+ NetworkPipelineStageId.Get(),
+#endif
+#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
+ NetworkPipelineStageId.Get(),
+#endif
+ };
+
+ var reliableSequenced = new NetworkPipelineStageId[]
+ {
+ NetworkPipelineStageId.Get(),
+#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
+ NetworkPipelineStageId.Get(),
+#endif
+#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
+ NetworkPipelineStageId.Get(),
+#endif
+ };
+
+ unreliableFragmentedPipelineStages = new(unreliableFragmented, Allocator.Temp);
+ unreliableSequencedFragmentedPipelineStages = new(unreliableSequencedFragmented, Allocator.Temp);
+ reliableSequencedPipelineStages = new(reliableSequenced, Allocator.Temp);
+ }
+
private NetworkPipeline SelectSendPipeline(NetworkDelivery delivery)
{
switch (delivery)
@@ -509,6 +661,7 @@ private NetworkPipeline SelectSendPipeline(NetworkDelivery delivery)
return NetworkPipeline.Null;
}
}
+
#if HOSTNAME_RESOLUTION_AVAILABLE && UTP_TRANSPORT_2_4_ABOVE
private static bool IsValidFqdn(string fqdn)
{
@@ -525,15 +678,6 @@ private bool ClientBindAndConnect()
if (m_ProtocolType == ProtocolType.RelayUnityTransport)
{
- //This comparison is currently slow since RelayServerData does not implement a custom comparison operator that doesn't use
- //reflection, but this does not live in the context of a performance-critical loop, it runs once at initial connection time.
- if (m_RelayServerData.Equals(default(RelayServerData)))
- {
- Debug.LogError("You must call SetRelayServerData() at least once before calling StartClient.");
- return false;
- }
-
- m_NetworkSettings.WithRelayParameters(ref m_RelayServerData, m_HeartbeatTimeoutMS);
serverEndpoint = m_RelayServerData.Endpoint;
}
else
@@ -747,22 +891,6 @@ public void SetDebugSimulatorParameters(int packetDelay, int packetJitter, int d
};
}
- private bool StartRelayServer()
- {
- //This comparison is currently slow since RelayServerData does not implement a custom comparison operator that doesn't use
- //reflection, but this does not live in the context of a performance-critical loop, it runs once at initial connection time.
- if (m_RelayServerData.Equals(default(RelayServerData)))
- {
- Debug.LogError("You must call SetRelayServerData() at least once before calling StartServer.");
- return false;
- }
- else
- {
- m_NetworkSettings.WithRelayParameters(ref m_RelayServerData, m_HeartbeatTimeoutMS);
- return ServerBindAndListen(NetworkEndpoint.AnyIpv4);
- }
- }
-
[BurstCompile]
private struct SendBatchedMessagesJob : IJob
{
@@ -1301,26 +1429,6 @@ public override void Initialize(NetworkManager networkManager = null)
}
m_RealTimeProvider = m_NetworkManager ? m_NetworkManager.RealTimeProvider : new RealTimeProvider();
-
- m_NetworkSettings = new NetworkSettings(Allocator.Persistent);
-
- // If the user sends a message of exactly m_MaxPayloadSize in length, we need to
- // account for the overhead of its length when we store it in the send queue.
- var fragmentationCapacity = m_MaxPayloadSize + BatchedSendQueue.PerMessageOverhead;
- m_NetworkSettings.WithFragmentationStageParameters(payloadCapacity: fragmentationCapacity);
-
- // Bump the reliable window size to its maximum size of 64. Since NGO makes heavy use of
- // reliable delivery, we're better off with the increased window size compared to the
- // extra 4 bytes of header that this costs us.
- //
- // We also increase the maximum resend timeout since the default one in UTP is very
- // aggressive (optimized for latency and low bandwidth). With NGO, it's too low and
- // we sometimes notice a lot of useless resends, especially if using Relay. (We can
- // only do this with UTP 2.0 because 1.X doesn't support that parameter.)
- m_NetworkSettings.WithReliableStageParameters(
- windowSize: 64,
- maximumResendTime: m_ProtocolType == ProtocolType.RelayUnityTransport ? 750 : 500
- );
}
///
@@ -1463,26 +1571,17 @@ public override bool StartServer()
return false;
}
- bool succeeded;
- switch (m_ProtocolType)
+ var listenEndpoint = m_ProtocolType == ProtocolType.UnityTransport
+ ? ConnectionData.ListenEndPoint
+ : NetworkEndpoint.AnyIpv4;
+
+ var succeeded = ServerBindAndListen(listenEndpoint);
+ if (!succeeded && m_Driver.IsCreated)
{
- case ProtocolType.UnityTransport:
- succeeded = ServerBindAndListen(ConnectionData.ListenEndPoint);
- if (!succeeded && m_Driver.IsCreated)
- {
- m_Driver.Dispose();
- }
- return succeeded;
- case ProtocolType.RelayUnityTransport:
- succeeded = StartRelayServer();
- if (!succeeded && m_Driver.IsCreated)
- {
- m_Driver.Dispose();
- }
- return succeeded;
- default:
- return false;
+ m_Driver.Dispose();
}
+
+ return succeeded;
}
///
@@ -1524,23 +1623,6 @@ public override void Shutdown()
m_ServerClientId = default;
}
- private void ConfigureSimulator()
- {
- // As DebugSimulator is deprecated, the 'packetDelayMs', 'packetJitterMs' and 'packetDropPercentage'
- // parameters are set to the default and are supposed to be changed using Network Simulator tool instead.
- m_NetworkSettings.WithSimulatorStageParameters(
- maxPacketCount: 300, // TODO Is there any way to compute a better value?
- maxPacketSize: NetworkParameterConstants.MTU,
- packetDelayMs: 0,
- packetJitterMs: 0,
- packetDropPercentage: 0,
- randomSeed: DebugSimulatorRandomSeed ?? (uint)System.Diagnostics.Stopwatch.GetTimestamp()
- , mode: ApplyMode.AllPackets
- );
-
- m_NetworkSettings.WithNetworkSimulatorParameters();
- }
-
///
protected override NetworkTopologyTypes OnCurrentTopology()
{
@@ -1586,30 +1668,14 @@ public void SetClientSecrets(string serverCommonName, string caCertificate = nul
m_ClientCaCertificate = caCertificate;
}
- ///
- /// Creates the internal NetworkDriver
- ///
- /// The owner transport
- /// The driver
- /// The UnreliableFragmented NetworkPipeline
- /// The UnreliableSequencedFragmented NetworkPipeline
- /// The ReliableSequenced NetworkPipeline
- public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
+ ///
+ public void CreateDriver(
+ UnityTransport transport,
+ out NetworkDriver driver,
out NetworkPipeline unreliableFragmentedPipeline,
out NetworkPipeline unreliableSequencedFragmentedPipeline,
out NetworkPipeline reliableSequencedPipeline)
{
-#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
- ConfigureSimulator();
-#endif
- m_NetworkSettings.WithNetworkConfigParameters(
- maxConnectAttempts: transport.m_MaxConnectAttempts,
- connectTimeoutMS: transport.m_ConnectTimeoutMS,
- disconnectTimeoutMS: transport.m_DisconnectTimeoutMS,
- sendQueueCapacity: m_MaxPacketQueueSize,
- receiveQueueCapacity: m_MaxPacketQueueSize,
- heartbeatTimeoutMS: transport.m_HeartbeatTimeoutMS);
-
#if UNITY_WEBGL && !UNITY_EDITOR
if (m_NetworkManager.IsServer && m_ProtocolType != ProtocolType.RelayUnityTransport)
{
@@ -1632,48 +1698,6 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
}
#endif
- if (m_UseEncryption)
- {
- if (m_ProtocolType == ProtocolType.RelayUnityTransport)
- {
- if (m_RelayServerData.IsSecure == 0)
- {
- // log an error because we have mismatched configuration
- Debug.LogError("Mismatched security configuration, between Relay and local NetworkManager settings");
- }
-
- // No need to to anything else if using Relay because UTP will handle the
- // configuration of the security parameters on its own.
- }
- else
- {
- if (m_NetworkManager.IsServer)
- {
- if (string.IsNullOrEmpty(m_ServerCertificate) || string.IsNullOrEmpty(m_ServerPrivateKey))
- {
- throw new Exception("In order to use encrypted communications, when hosting, you must set the server certificate and key.");
- }
-
- m_NetworkSettings.WithSecureServerParameters(m_ServerCertificate, m_ServerPrivateKey);
- }
- else
- {
- if (string.IsNullOrEmpty(m_ServerCommonName))
- {
- throw new Exception("In order to use encrypted communications, clients must set the server common name.");
- }
- else if (string.IsNullOrEmpty(m_ClientCaCertificate))
- {
- m_NetworkSettings.WithSecureClientParameters(m_ServerCommonName);
- }
- else
- {
- m_NetworkSettings.WithSecureClientParameters(m_ClientCaCertificate, m_ServerCommonName);
- }
- }
- }
- }
-
if (m_ProtocolType == ProtocolType.RelayUnityTransport)
{
if (m_UseWebSockets && m_RelayServerData.IsWebSocket == 0)
@@ -1689,15 +1713,15 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
if (m_UseWebSockets)
{
- driver = NetworkDriver.Create(new WebSocketNetworkInterface(), m_NetworkSettings);
+ driver = NetworkDriver.Create(new WebSocketNetworkInterface(), GetDefaultNetworkSettings());
}
else
{
#if UNITY_WEBGL && !UNITY_EDITOR
Debug.LogWarning($"WebSockets were used even though they're not selected in NetworkManager. You should check {nameof(UseWebSockets)}', on the Unity Transport component, to silence this warning.");
- driver = NetworkDriver.Create(new WebSocketNetworkInterface(), m_NetworkSettings);
+ driver = NetworkDriver.Create(new WebSocketNetworkInterface(), GetDefaultNetworkSettings());
#else
- driver = NetworkDriver.Create(new UDPNetworkInterface(), m_NetworkSettings);
+ driver = NetworkDriver.Create(new UDPNetworkInterface(), GetDefaultNetworkSettings());
#endif
}
@@ -1705,48 +1729,14 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
driver.RegisterPipelineStage(new NetworkMetricsPipelineStage());
#endif
- SetupPipelines(driver,
- out unreliableFragmentedPipeline,
- out unreliableSequencedFragmentedPipeline,
- out reliableSequencedPipeline);
- }
-
- private void SetupPipelines(NetworkDriver driver,
- out NetworkPipeline unreliableFragmentedPipeline,
- out NetworkPipeline unreliableSequencedFragmentedPipeline,
- out NetworkPipeline reliableSequencedPipeline)
- {
-
- unreliableFragmentedPipeline = driver.CreatePipeline(
- typeof(FragmentationPipelineStage)
-#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
- , typeof(SimulatorPipelineStage)
-#endif
-#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
- , typeof(NetworkMetricsPipelineStage)
-#endif
- );
-
- unreliableSequencedFragmentedPipeline = driver.CreatePipeline(
- typeof(FragmentationPipelineStage),
- typeof(UnreliableSequencedPipelineStage)
-#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
- , typeof(SimulatorPipelineStage)
-#endif
-#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
- , typeof(NetworkMetricsPipelineStage)
-#endif
- );
+ GetDefaultPipelineConfigurations(
+ out var unreliableFragmentedPipelineStages,
+ out var unreliableSequencedFragmentedPipelineStages,
+ out var reliableSequencedPipelineStages);
- reliableSequencedPipeline = driver.CreatePipeline(
- typeof(ReliableSequencedPipelineStage)
-#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
- , typeof(SimulatorPipelineStage)
-#endif
-#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
- , typeof(NetworkMetricsPipelineStage)
-#endif
- );
+ unreliableFragmentedPipeline = driver.CreatePipeline(unreliableFragmentedPipelineStages);
+ unreliableSequencedFragmentedPipeline = driver.CreatePipeline(unreliableSequencedFragmentedPipelineStages);
+ reliableSequencedPipeline = driver.CreatePipeline(reliableSequencedPipelineStages);
}
// -------------- Utility Types -------------------------------------------------------------------------------