Class NetworkSettingsAttribute
This attribute is used to configure the network settings of scripts that are derived from the NetworkBehaviour base class.
using UnityEngine.Networking;
[NetworkSettings(channel = 1, sendInterval = 0.2f)]
class MyScript : NetworkBehaviour
{
[SyncVar]
int value;
}
Namespace: UnityEngine.Networking
Syntax
[AttributeUsage(AttributeTargets.Class)]
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class NetworkSettingsAttribute : Attribute, _Attribute
Fields
channel
The QoS channel to use for updates for this script.
Updates for SyncVar variables will be sent on the specified QoS channel. The default channel for scripts is zero.
Declaration
public int channel
Field Value
Type | Description |
---|---|
Int32 |
sendInterval
The sendInterval control how frequently updates are sent for this script.
If sendInterval is zero, updates will be sent at the end of the frame when dirty bits are set for that script. Note that setting the value of a SyncVar will automatically set dirty bits.
If sendInterval is non-zero, updates are deferred until sendInterval seconds have passed since the last update for that script. So it can be used as a throttle in cases where the Sync value is changing constantly on the server, but you don't want it to be updated every frame.
The default sendInterval for scripts is 0.1f seconds.
The send interval can also be customized by implementing the virtual function GetNetworkSendInterval() on NetworkBehaviour.
Declaration
public float sendInterval
Field Value
Type | Description |
---|---|
Single |