Skip to main content

Unity.Netcode.NetworkVariable-1

A variable that can be synchronized over the network.

Inheritance#

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

Implements#

System.IDisposable

Inherited Members#

NetworkVariableBase.Initialize(NetworkBehaviour)

NetworkVariableBase.Name

NetworkVariableBase.ReadPerm

NetworkVariableBase.SetDirty(Boolean)

NetworkVariableBase.ResetDirty()

NetworkVariableBase.IsDirty()

NetworkVariableBase.ShouldWrite(UInt64, Boolean)

NetworkVariableBase.CanClientRead(UInt64)

NetworkVariableBase.Dispose()

Object.Equals(Object)

Object.Equals(Object, Object)

Object.GetHashCode()

Object.GetType()

Object.MemberwiseClone()

Object.ReferenceEquals(Object, Object)

Object.ToString()

Namespace: System.Dynamic.ExpandoObject#
Assembly: MLAPI.dll#
Syntax#
[Serializable]
public class NetworkVariable<T> : NetworkVariableBase, IDisposable where T : struct
Type Parameters#
NameDescription
T

NetworkVariable()#

Creates a NetworkVariable with the default value and custom read permission

Declaration#

public NetworkVariable()

NetworkVariable(T)#

Creates a NetworkVariable with a custom value and the default read permission

Declaration#

public NetworkVariable(T value)

Parameters#

TypeNameDescription
TvalueThe initial value to use for the NetworkVariable

NetworkVariable(NetworkVariableReadPermission)#

Creates a NetworkVariable with the default value and custom read permission

Declaration#

public NetworkVariable(NetworkVariableReadPermission readPerm)

Parameters#

TypeNameDescription
NetworkVariableReadPermissionreadPermThe read permission for the NetworkVariable

NetworkVariable(NetworkVariableReadPermission, T)#

Creates a NetworkVariable with a custom value and custom settings

Declaration#

public NetworkVariable(NetworkVariableReadPermission readPerm, T value)

Parameters#

TypeNameDescription
NetworkVariableReadPermissionreadPermThe read permission for the NetworkVariable
TvalueThe initial value to use for the NetworkVariable

#

OnValueChanged#

The callback to be invoked when the value gets changed

Declaration#

public NetworkVariable<T>.OnValueChangedDelegate OnValueChanged

Field Value#

TypeDescription
NetworkVariable.OnValueChangedDelegate\<>

#

Value#

The value of the NetworkVariable container

Declaration#

public virtual T Value { get; set; }

Property Value#

TypeDescription
T

#

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