Skip to content

Commit e119b12

Browse files
authored
Merge branch 'develop-2.0.0' into fix/destroy-in-scene-placed-objects
2 parents 1113909 + f70eab1 commit e119b12

File tree

4 files changed

+290
-213
lines changed

4 files changed

+290
-213
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
### Added
1212

13+
- 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)
1314
- Added mappings between `ClientId` and `TransportId`. (#3516)
1415
- Added `NetworkPrefabInstanceHandlerWithData<T>`, a variant of `INetworkPrefabInstanceHandler` that provides access to custom instantiation data directly within the `Instantiate()` method. (#3430)
1516

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using Unity.Networking.Transport;
2+
3+
namespace Unity.Netcode.Transports.UTP
4+
{
5+
/// <summary>
6+
/// <para>
7+
/// This interface allows one to override the creation of the <see cref="NetworkDriver"/> object
8+
/// that will be used under the hood by <see cref="UnityTransport"/>. This can be useful when
9+
/// implementing a custom <see cref="INetworkInterface"/> or to add custom pipeline stages to
10+
/// the default pipelines.
11+
/// </para>
12+
/// <para>
13+
/// To use a custom driver constructor, set <see cref="UnityTransport.s_DriverConstructor"/> to
14+
/// an instance of an implementation of this interface. This must be done before calling
15+
/// <see cref="UnityTransport.StartClient"/> or <see cref="UnityTransport.StartServer"/>.
16+
/// </para>
17+
/// </summary>
18+
/// <example>
19+
/// <para>
20+
/// This example implements a custom driver constructor that uses the IPC network interface from
21+
/// the Unity Transport package. This network interface is used for intra-process communications
22+
/// which can be useful for implementing a single-player version of a game. Since the example is
23+
/// also preserving all the default settings and pipelines, you'd also benefit from all the
24+
/// existing features of the transport, like integration with the Network Profiler.
25+
/// </para>
26+
/// <code>
27+
/// public class IPCDriverConstructor : INetworkStreamDriverConstructor
28+
/// {
29+
/// public void CreateDriver(
30+
/// UnityTransport transport,
31+
/// out NetworkDriver driver,
32+
/// out NetworkPipeline unreliableFragmentedPipeline,
33+
/// out NetworkPipeline unreliableSequencedFragmentedPipeline,
34+
/// out NetworkPipeline reliableSequencedPipeline)
35+
/// {
36+
/// var settings = transport.GetDefaultNetworkSettings();
37+
/// driver = NetworkDriver.Create(new IPCNetworkInterface(), settings);
38+
///
39+
/// transport.GetDefaultPipelineConfigurations(
40+
/// out var unreliableFragmentedPipelineStages,
41+
/// out var unreliableSequencedFragmentedPipelineStages,
42+
/// out var reliableSequencedPipelineStages);
43+
///
44+
/// unreliableFragmentedPipeline = driver.CreatePipeline(unreliableFragmentedPipelineStages);
45+
/// unreliableSequencedFragmentedPipeline = driver.CreatePipeline(unreliableSequencedFragmentedPipelineStages);
46+
/// reliableSequencedPipeline = driver.CreatePipeline(reliableSequencedPipelineStages);
47+
/// }
48+
/// }
49+
/// </code>
50+
/// </example>
51+
public interface INetworkStreamDriverConstructor
52+
{
53+
/// <summary>
54+
/// Creates the <see cref="NetworkDriver"/> instance to be used by the transport.
55+
/// </summary>
56+
/// <param name="transport">The transport for which the driver is created.</param>
57+
/// <param name="driver">The newly-created <see cref="NetworkDriver"/>.</param>
58+
/// <param name="unreliableFragmentedPipeline">
59+
/// The driver's pipeline on which to send unreliable traffic. This pipeline must also
60+
/// support fragmentation (payloads larger than the MTU).
61+
/// </param>
62+
/// <param name="unreliableSequencedFragmentedPipeline">
63+
/// The driver's pipeline on which to send unreliable but sequenced traffic. Traffic sent
64+
/// on this pipeline must be delivered in the right order, although packet loss is okay.
65+
/// This pipeline must also support fragmentation (payloads larger than the MTU).
66+
/// </param>
67+
/// <param name="reliableSequencedPipeline">
68+
/// The driver's pipeline on which to send reliable traffic. This pipeline must ensure that
69+
/// all of its traffic is delivered, and in the correct order too. There is no need for that
70+
/// pipeline to support fragmentation (<see cref="UnityTransport"/> will handle that).
71+
/// </param>
72+
void CreateDriver(
73+
UnityTransport transport,
74+
out NetworkDriver driver,
75+
out NetworkPipeline unreliableFragmentedPipeline,
76+
out NetworkPipeline unreliableSequencedFragmentedPipeline,
77+
out NetworkPipeline reliableSequencedPipeline);
78+
}
79+
}

com.unity.netcode.gameobjects/Runtime/Transports/UTP/INetworkStreamDriverConstructor.cs.meta

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

Comments
 (0)