定义在 SendUpdate 超时自动增加(发送率自动降低)之前由于网络状况而需要丢弃的数据包的百分比(从 0 到 100)。默认值 = 5。
To avoid receiver overflow, Unity Multiplayer supports flow control. Each ping packet sent between connected peers contains two values:
(1) Packets lost due to network conditions.
(2) Packets lost because the receiver does not have free space in its incoming buffers.
Like OverflowDropThreshold, both values are reported in percent. Use NetworkDropThreshold and OverflowDropThreshold to set thresholds for these values. If a value reported in the ping packet exceeds the corresponding threshold, Unity Multiplayer increases the sending timeout for packets up to a maximum value of DisconnectTimeout.
注意:无线网络的数据包丢失率通常为 5% 或以上。对于无线网络,明智的做法是将 NetworkDropThreshold 设置为 40-50%。
using UnityEngine; using UnityEngine.Networking;
public class ExampleScript : NetworkBehaviour { void Start() { ConnectionConfig myConfig = new ConnectionConfig(); myConfig.AddChannel(QosType.Unreliable); myConfig.AddChannel(QosType.UnreliableFragmented); myConfig.NetworkDropThreshold = 50; //50% myConfig.OverflowDropThreshold = 10; //10% } }