Skip to main content

Class NetworkVariableBase

Interface for network value containers

Inheritance

System.Object

NetworkVariableBase

NetworkList\<T>

NetworkVariable\<T>

Implements

System.IDisposable

Inherited Members

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()

Namespace: Unity.Netcode
Assembly: MLAPI.dll
Syntax
public abstract class NetworkVariableBase : IDisposable

Constructors

NetworkVariableBase(NetworkVariableReadPermission, NetworkVariableWritePermission)

The default constructor for NetworkVariableBase that can be used to create a custom NetworkVariable.

Declaration
protected NetworkVariableBase(NetworkVariableReadPermission readPerm = NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission writePerm = NetworkVariableWritePermission.Server)
Parameters
TypeNameDescription
NetworkVariableReadPermissionreadPermthe NetworkVariableReadPermission access settings
NetworkVariableWritePermissionwritePermthe NetworkVariableWritePermission access settings

Fields

DefaultReadPerm

The default read permissions

Declaration
public const NetworkVariableReadPermission DefaultReadPerm = NetworkVariableReadPermission.Everyone
Field Value
TypeDescription
NetworkVariableReadPermission

DefaultWritePerm

The default write permissions

Declaration
public const NetworkVariableWritePermission DefaultWritePerm = NetworkVariableWritePermission.Server
Field Value
TypeDescription
NetworkVariableWritePermission

ReadPerm

The read permission for this var

Declaration
public readonly NetworkVariableReadPermission ReadPerm
Field Value
TypeDescription
NetworkVariableReadPermission

WritePerm

The write permission for this var

Declaration
public readonly NetworkVariableWritePermission WritePerm
Field Value
TypeDescription
NetworkVariableWritePermission

Properties

Name

Gets or sets the name of the network variable's instance (MemberInfo) where it was declared.

Declaration
public string Name { get; }
Property Value
TypeDescription
System.String

Methods

CanClientRead(UInt64)

Gets if a specific client has permission to read the var or not

Declaration
public bool CanClientRead(ulong clientId)
Parameters
TypeNameDescription
System.UInt64clientIdThe client id
Returns
TypeDescription
System.BooleanWhether or not the client has permission to read

CanClientWrite(UInt64)

Gets if a specific client has permission to write the var or not

Declaration
public bool CanClientWrite(ulong clientId)
Parameters
TypeNameDescription
System.UInt64clientIdThe client id
Returns
TypeDescription
System.BooleanWhether or not the client has permission to write

Dispose()

Virtual System.IDisposable implementation

Declaration
public virtual void Dispose()

Initialize(NetworkBehaviour)

Initializes the NetworkVariable

Declaration
public void Initialize(NetworkBehaviour networkBehaviour)
Parameters
TypeNameDescription
NetworkBehaviournetworkBehaviourThe NetworkBehaviour the NetworkVariable belongs to

IsDirty()

Gets Whether or not the container is dirty

Declaration
public virtual bool IsDirty()
Returns
TypeDescription
System.BooleanWhether or not the container is dirty

ReadDelta(FastBufferReader, Boolean)

Reads delta from the reader and applies them to the internal value

Declaration
public abstract void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
Parameters
TypeNameDescription
FastBufferReaderreaderThe stream to read the delta from
System.BooleankeepDirtyDeltaWhether or not the delta should be kept as dirty or consumed

ReadField(FastBufferReader)

Reads the complete state from the reader and applies it

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

ResetDirty()

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

Declaration
public virtual void ResetDirty()

SetDirty(Boolean)

Sets whether or not the variable needs to be delta synced

Declaration
public virtual void SetDirty(bool isDirty)
Parameters
TypeNameDescription
System.BooleanisDirtyWhether or not the var is dirty

WriteDelta(FastBufferWriter)

Writes the dirty changes, that is, the changes since the variable was last dirty, to the writer

Declaration
public abstract void WriteDelta(FastBufferWriter writer)
Parameters
TypeNameDescription
FastBufferWriterwriterThe stream to write the dirty changes to

WriteField(FastBufferWriter)

Writes the complete state of the variable to the writer

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

Implements

System.IDisposable