Skip to content

Commit 32b71ff

Browse files
feat: MTT-2888: Add properties for UnityTransport settings (#1845)
* feat: MTT-2888: Add properties for UnityTransport settings * Add PR number to CHANGELOG entry
1 parent 3e9923c commit 32b71ff

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1212
- Added editor only check prior to entering into play mode if the currently open and active scene is in the build list and if not displays a dialog box asking the user if they would like to automatically add it prior to entering into play mode. (#1828)
1313
- Added `UnityTransport` implementation and `com.unity.transport` package dependency (#1823)
1414
- Added `NetworkVariableWritePermission` to `NetworkVariableBase` and implemented `Owner` client writable netvars. (#1762)
15+
- `UnityTransport` settings can now be set programmatically. (#1845)
1516

1617
### Changed
1718
- Updated `UnityTransport` dependency on `com.unity.transport` to 1.0.0-pre.16. (#1834)

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,96 @@ private enum State
9797
[SerializeField]
9898
private ProtocolType m_ProtocolType;
9999

100-
#pragma warning disable CS0414 // Assigned-but-not-used (only an issue in WebGL builds)
101100
[Tooltip("The maximum amount of packets that can be in the internal send/receive queues. Basically this is how many packets can be sent/received in a single update/frame.")]
102101
[SerializeField]
103102
private int m_MaxPacketQueueSize = InitialMaxPacketQueueSize;
104-
#pragma warning restore CS0414
103+
104+
/// <summary>The maximum amount of packets that can be in the internal send/receive queues.</summary>
105+
/// <remarks>Basically this is how many packets can be sent/received in a single update/frame.</remarks>
106+
public int MaxPacketQueueSize
107+
{
108+
get => m_MaxPacketQueueSize;
109+
set => m_MaxPacketQueueSize = value;
110+
}
105111

106112
[Tooltip("The maximum size of a payload that can be handled by the transport.")]
107113
[SerializeField]
108114
private int m_MaxPayloadSize = InitialMaxPayloadSize;
109115

116+
/// <summary>The maximum size of a payload that can be handled by the transport.</summary>
117+
public int MaxPayloadSize
118+
{
119+
get => m_MaxPayloadSize;
120+
set => m_MaxPayloadSize = value;
121+
}
122+
110123
[Tooltip("The maximum size in bytes of the transport send queue. The send queue accumulates messages for batching and stores messages when other internal send queues are full. If you routinely observe an error about too many in-flight packets, try increasing this.")]
111124
[SerializeField]
112125
private int m_MaxSendQueueSize = InitialMaxSendQueueSize;
113126

114-
[Tooltip("A timeout in milliseconds after which a heartbeat is sent if there is no activity.")]
127+
/// <summary>The maximum size in bytes of the transport send queue.</summary>
128+
/// <remarks>
129+
/// The send queue accumulates messages for batching and stores messages when other internal
130+
/// send queues are full. If you routinely observe an error about too many in-flight packets,
131+
/// try increasing this.
132+
/// </remarks>
133+
public int MaxSendQueueSize
134+
{
135+
get => m_MaxSendQueueSize;
136+
set => m_MaxSendQueueSize = value;
137+
}
138+
139+
[Tooltip("Timeout in milliseconds after which a heartbeat is sent if there is no activity.")]
115140
[SerializeField]
116141
private int m_HeartbeatTimeoutMS = NetworkParameterConstants.HeartbeatTimeoutMS;
117142

118-
[Tooltip("A timeout in milliseconds indicating how long we will wait until we send a new connection attempt.")]
143+
/// <summary>Timeout in milliseconds after which a heartbeat is sent if there is no activity.</summary>
144+
public int HeartbeatTimeoutMS
145+
{
146+
get => m_HeartbeatTimeoutMS;
147+
set => m_HeartbeatTimeoutMS = value;
148+
}
149+
150+
[Tooltip("Timeout in milliseconds indicating how long we will wait until we send a new connection attempt.")]
119151
[SerializeField]
120152
private int m_ConnectTimeoutMS = NetworkParameterConstants.ConnectTimeoutMS;
121153

154+
/// <summary>
155+
/// Timeout in milliseconds indicating how long we will wait until we send a new connection attempt.
156+
/// </summary>
157+
public int ConnectTimeoutMS
158+
{
159+
get => m_ConnectTimeoutMS;
160+
set => m_ConnectTimeoutMS = value;
161+
}
162+
122163
[Tooltip("The maximum amount of connection attempts we will try before disconnecting.")]
123164
[SerializeField]
124165
private int m_MaxConnectAttempts = NetworkParameterConstants.MaxConnectAttempts;
125166

126-
[Tooltip("A timeout in milliseconds indicating how long we will wait for a connection event, before we disconnect it. The connection needs to receive data from the connected endpoint within this timeout. Note that with heartbeats enabled, simply not sending any data will not be enough to trigger this timeout (since heartbeats count as connection events).")]
167+
/// <summary>The maximum amount of connection attempts we will try before disconnecting.</summary>
168+
public int MaxConnectAttempts
169+
{
170+
get => m_MaxConnectAttempts;
171+
set => m_MaxConnectAttempts = value;
172+
}
173+
174+
[Tooltip("Inactivity timeout after which a connection will be disconnected. The connection needs to receive data from the connected endpoint within this timeout. Note that with heartbeats enabled, simply not sending any data will not be enough to trigger this timeout (since heartbeats count as connection events).")]
127175
[SerializeField]
128176
private int m_DisconnectTimeoutMS = NetworkParameterConstants.DisconnectTimeoutMS;
129177

178+
/// <summary>Inactivity timeout after which a connection will be disconnected.</summary>
179+
/// <remarks>
180+
/// The connection needs to receive data from the connected endpoint within this timeout.
181+
/// Note that with heartbeats enabled, simply not sending any data will not be enough to
182+
/// trigger this timeout (since heartbeats count as connection events).
183+
/// </remarks>
184+
public int DisconnectTimeoutMS
185+
{
186+
get => m_DisconnectTimeoutMS;
187+
set => m_DisconnectTimeoutMS = value;
188+
}
189+
130190
[Serializable]
131191
public struct ConnectionAddressData
132192
{

0 commit comments

Comments
 (0)