Class NetworkVariableBase
Interface for network value containers
Implements
Inherited Members
Namespace: Unity.Netcode
Assembly: solution.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
Type | Name | Description |
---|---|---|
NetworkVariableReadPermission | readPerm | the NetworkVariableReadPermission access settings |
NetworkVariableWritePermission | writePerm | the NetworkVariableWritePermission access settings |
Fields
DefaultReadPerm
The default read permissions
Declaration
public const NetworkVariableReadPermission DefaultReadPerm = Everyone
Field Value
Type | Description |
---|---|
NetworkVariableReadPermission |
DefaultWritePerm
The default write permissions
Declaration
public const NetworkVariableWritePermission DefaultWritePerm = Server
Field Value
Type | Description |
---|---|
NetworkVariableWritePermission |
ReadPerm
The read permission for this var
Declaration
public readonly NetworkVariableReadPermission ReadPerm
Field Value
Type | Description |
---|---|
NetworkVariableReadPermission |
WritePerm
The write permission for this var
Declaration
public readonly NetworkVariableWritePermission WritePerm
Field Value
Type | Description |
---|---|
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
Type | Description |
---|---|
string |
Methods
CanClientRead(ulong)
Gets if a specific client has permission to read the var or not
Declaration
public bool CanClientRead(ulong clientId)
Parameters
Type | Name | Description |
---|---|---|
ulong | clientId | The client id |
Returns
Type | Description |
---|---|
bool | Whether or not the client has permission to read |
CanClientWrite(ulong)
Gets if a specific client has permission to write the var or not
Declaration
public bool CanClientWrite(ulong clientId)
Parameters
Type | Name | Description |
---|---|---|
ulong | clientId | The client id |
Returns
Type | Description |
---|---|
bool | Whether or not the client has permission to write |
Dispose()
Virtual IDisposable implementation
Declaration
public virtual void Dispose()
GetBehaviour()
Declaration
public NetworkBehaviour GetBehaviour()
Returns
Type | Description |
---|---|
NetworkBehaviour |
Initialize(NetworkBehaviour)
Initializes the NetworkVariable
Declaration
public void Initialize(NetworkBehaviour networkBehaviour)
Parameters
Type | Name | Description |
---|---|---|
NetworkBehaviour | networkBehaviour | The NetworkBehaviour the NetworkVariable belongs to |
IsDirty()
Gets Whether or not the container is dirty
Declaration
public virtual bool IsDirty()
Returns
Type | Description |
---|---|
bool | Whether or not the container is dirty |
MarkNetworkBehaviourDirty()
Declaration
protected void MarkNetworkBehaviourDirty()
ReadDelta(FastBufferReader, bool)
Reads delta from the reader and applies them to the internal value
Declaration
public abstract void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
Parameters
Type | Name | Description |
---|---|---|
FastBufferReader | reader | The stream to read the delta from |
bool | keepDirtyDelta | Whether 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
Type | Name | Description |
---|---|---|
FastBufferReader | reader | The stream to read the state from |
ResetDirty()
Resets the dirty state and marks the variable as synced / clean
Declaration
public virtual void ResetDirty()
SetDirty(bool)
Sets whether or not the variable needs to be delta synced
Declaration
public virtual void SetDirty(bool isDirty)
Parameters
Type | Name | Description |
---|---|---|
bool | isDirty | Whether 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
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The 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
Type | Name | Description |
---|---|---|
FastBufferWriter | writer | The stream to write the state to |