Skip to main content

Unity.Netcode.NetworkVariable-1

A variable that can be synchronized over the network.

Inheritance#

System.Object

NetworkVariableBase

NetworkVariableSerialization\<T>

NetworkVariable\<T>

Implements#

System.IDisposable

Inherited Members#

NetworkVariableSerialization\<T>.Write(FastBufferWriter, T)

NetworkVariableSerialization\<T>.Read(FastBufferReader, T)

NetworkVariableBase.Initialize(NetworkBehaviour)

NetworkVariableBase.DefaultReadPerm

NetworkVariableBase.DefaultWritePerm

NetworkVariableBase.Name

NetworkVariableBase.ReadPerm

NetworkVariableBase.WritePerm

NetworkVariableBase.SetDirty(Boolean)

NetworkVariableBase.ResetDirty()

NetworkVariableBase.IsDirty()

NetworkVariableBase.CanClientRead(UInt64)

NetworkVariableBase.CanClientWrite(UInt64)

NetworkVariableBase.Dispose()

System.Object.Equals(System.Object)

System.Object.Equals(System.Object, System.Object)

System.Object.GetHashCode()

System.Object.GetType()

System.Object.MemberwiseClone()

System.Object.ReferenceEquals(System.Object, System.Object)

System.Object.ToString()

Syntax#
[Serializable]
public class NetworkVariable<T> : NetworkVariableSerialization<T>, IDisposable where T : struct
Type Parameters#
NameDescription
T

Constructors#

NetworkVariable(T, NetworkVariableReadPermission, NetworkVariableWritePermission)#

Declaration#
public NetworkVariable(T value = default(T), NetworkVariableReadPermission readPerm = NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission writePerm = NetworkVariableWritePermission.Server)
Parameters#
TypeNameDescription
Tvalue
NetworkVariableReadPermissionreadPerm
NetworkVariableWritePermissionwritePerm

Fields#

OnValueChanged#

The callback to be invoked when the value gets changed

Declaration#
public NetworkVariable<T>.OnValueChangedDelegate OnValueChanged
Field Value#
TypeDescription
NetworkVariable.OnValueChangedDelegate\<>

Properties#

Value#

The value of the NetworkVariable container

Declaration#
public virtual T Value { get; set; }
Property Value#
TypeDescription
T

Methods#

ReadDelta(FastBufferReader, Boolean)#

Reads value from the reader and applies it

Declaration#
public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
Parameters#
TypeNameDescription
FastBufferReaderreaderThe stream to read the value from
System.BooleankeepDirtyDeltaWhether or not the container should keep the dirty delta, or mark the delta as consumed
Overrides#

NetworkVariableBase.ReadDelta(FastBufferReader, Boolean)

ReadField(FastBufferReader)#

Reads the complete state from the reader and applies it

Declaration#
public override void ReadField(FastBufferReader reader)
Parameters#
TypeNameDescription
FastBufferReaderreaderThe stream to read the state from
Overrides#

NetworkVariableBase.ReadField(FastBufferReader)

WriteDelta(FastBufferWriter)#

Writes the variable to the writer

Declaration#
public override void WriteDelta(FastBufferWriter writer)
Parameters#
TypeNameDescription
FastBufferWriterwriterThe stream to write the value to
Overrides#

NetworkVariableBase.WriteDelta(FastBufferWriter)

WriteField(FastBufferWriter)#

Writes the complete state of the variable to the writer

Declaration#
public override void WriteField(FastBufferWriter writer)
Parameters#
TypeNameDescription
FastBufferWriterwriterThe stream to write the state to
Overrides#

NetworkVariableBase.WriteField(FastBufferWriter)

Implements#

System.IDisposable