Class NetworkSettingsAttribute | Multiplayer HLAPI | 1.0.8
docs.unity3d.com
    Show / Hide Table of Contents

    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;
    }
    Inheritance
    Object
    Attribute
    NetworkSettingsAttribute
    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
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023