Skip to main content

MLAPI.NetworkVariable.NetworkVariable-1

A variable that can be synchronized over the network.

Inheritance#

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

System.Dynamic.ExpandoObject

Implements#

INetworkVariable

Inherited Members#

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> : INetworkVariable
Type Parameters#
NameDescription
T

Constructors#

NetworkVariable()#

Creates a NetworkVariable with the default value and settings

Declaration#

public NetworkVariable()

NetworkVariable(T)#

Creates a NetworkVariable with a custom value and the default settings

Declaration#

public NetworkVariable(T value)

Parameters#

TypeNameDescription
TvalueThe initial value to use for the NetworkVariable

NetworkVariable(NetworkVariableSettings)#

Creates a NetworkVariable with the default value and custom settings

Declaration#

public NetworkVariable(NetworkVariableSettings settings)

Parameters#

TypeNameDescription
NetworkVariableSettingssettingsThe settings to use for the NetworkVariable

NetworkVariable(NetworkVariableSettings, T)#

Creates a NetworkVariable with a custom value and custom settings

Declaration#

public NetworkVariable(NetworkVariableSettings settings, T value)

Parameters#

TypeNameDescription
NetworkVariableSettingssettingsThe settings to use for the NetworkVariable
TvalueThe initial value to use for the NetworkVariable

Fields#

OnValueChanged#

The callback to be invoked when the value gets changed

Declaration#

public NetworkVariable<T>.OnValueChangedDelegate OnValueChanged

Field Value#

TypeDescription
NetworkVariable.OnValueChangedDelegate<>

Settings#

The settings for this var

Declaration#

public readonly NetworkVariableSettings Settings

Field Value#

TypeDescription
NetworkVariableSettings

Properties#

LocalTick#

The last time the variable was written to locally

Declaration#

public ushort LocalTick { get; }

Property Value#

TypeDescription
System.UInt16

RemoteTick#

The last time the variable was written to remotely. Uses the remote timescale

Declaration#

public ushort RemoteTick { get; }

Property Value#

TypeDescription
System.UInt16

Value#

The value of the NetworkVariable container

Declaration#

public T Value { get; set; }

Property Value#

TypeDescription
T

Methods#

CanClientRead(UInt64)#

Gets Whether or not a specific client can read to the varaible

Declaration#

public bool CanClientRead(ulong clientId)

Parameters#

TypeNameDescription
System.UInt64clientIdThe clientId of the remote client

Returns#

TypeDescription
System.BooleanWhether or not the client can read to the variable

CanClientWrite(UInt64)#

Gets Whether or not a specific client can write to the varaible

Declaration#

public bool CanClientWrite(ulong clientId)

Parameters#

TypeNameDescription
System.UInt64clientIdThe clientId of the remote client

Returns#

TypeDescription
System.BooleanWhether or not the client can write to the variable

GetChannel()#

Returns the name of the channel to be used for syncing

Declaration#

public NetworkChannel GetChannel()

Returns#

TypeDescription
NetworkChannelThe name of the channel to be used for syncing

IsDirty()#

Gets Whether or not the container is dirty

Declaration#

public bool IsDirty()

Returns#

TypeDescription
System.BooleanWhether or not the container is dirty

ReadDelta(Stream, Boolean, UInt16, UInt16)#

Reads value from the reader and applies it

Declaration#

public void ReadDelta(Stream stream, bool keepDirtyDelta, ushort localTick, ushort remoteTick)

Parameters#

TypeNameDescription
System.IO.StreamstreamThe stream to read the value from
System.BooleankeepDirtyDeltaWhether or not the container should keep the dirty delta, or mark the delta as consumed
System.UInt16localTick
System.UInt16remoteTick

ReadField(Stream, UInt16, UInt16)#

Reads the complete state from the reader and applies it

Declaration#

public void ReadField(Stream stream, ushort localTick, ushort remoteTick)

Parameters#

TypeNameDescription
System.IO.StreamstreamThe stream to read the state from
System.UInt16localTickThe local network tick at which this var was written, on the machine it was written
System.UInt16remoteTickThe remote network tick at which this var was sent by the host

ResetDirty()#

Resets the dirty state and marks the variable as synced / clean

Declaration#

public void ResetDirty()

SetDirty(Boolean)#

Sets whether or not the variable needs to be delta synced

Declaration#

public void SetDirty(bool isDirty)

Parameters#

TypeNameDescription
System.BooleanisDirty

SetNetworkBehaviour(NetworkBehaviour)#

Sets NetworkBehaviour the container belongs to.

Declaration#

public void SetNetworkBehaviour(NetworkBehaviour behaviour)

Parameters#

TypeNameDescription
NetworkBehaviourbehaviourThe behaviour the container behaves to

WriteDelta(Stream)#

Writes the variable to the writer

Declaration#

public void WriteDelta(Stream stream)

Parameters#

TypeNameDescription
System.IO.StreamstreamThe stream to write the value to

WriteField(Stream)#

Writes the complete state of the variable to the writer

Declaration#

public void WriteField(Stream stream)

Parameters#

TypeNameDescription
System.IO.StreamstreamThe stream to write the state to

Implements#

INetworkVariable