Class NetworkBehaviour
Base class for networked components.
Inheritance
NetworkBehaviour
Assembly: doc.dll
Syntax
public abstract class NetworkBehaviour : MonoBehaviour
Fields
|
Improve this Doc
View Source
syncInterval
sync interval for OnSerialize (in seconds)
Declaration
public float syncInterval
Field Value
|
Improve this Doc
View Source
syncMode
sync mode for OnSerialize
Declaration
Field Value
|
Improve this Doc
View Source
syncObjects
Declaration
protected readonly List<SyncObject> syncObjects
Field Value
Properties
|
Improve this Doc
View Source
ComponentIndex
Returns the index of the component on this object
Declaration
public int ComponentIndex { get; }
Property Value
|
Improve this Doc
View Source
connectionToClient
Server's network connection to the client. This is only valid for player objects on the server.
Declaration
public NetworkConnectionToClient connectionToClient { get; }
Property Value
|
Improve this Doc
View Source
connectionToServer
Client's network connection to the server. This is only valid for player objects on the client.
Declaration
public NetworkConnection connectionToServer { get; }
Property Value
|
Improve this Doc
View Source
hasAuthority
True on client if that component has been assigned to the client. E.g. player, pets, henchmen.
Declaration
public bool hasAuthority { get; }
Property Value
|
Improve this Doc
View Source
isClient
True if this object is on the client and has been spawned by the server.
Declaration
public bool isClient { get; }
Property Value
|
Improve this Doc
View Source
isClientOnly
True if this object is on the client-only, not host.
Declaration
public bool isClientOnly { get; }
Property Value
|
Improve this Doc
View Source
isLocalPlayer
True if this object is the the client's own local player.
Declaration
public bool isLocalPlayer { get; }
Property Value
|
Improve this Doc
View Source
isServer
True if this object is on the server and has been spawned.
Declaration
public bool isServer { get; }
Property Value
|
Improve this Doc
View Source
isServerOnly
True if this object is on the server-only, not host.
Declaration
public bool isServerOnly { get; }
Property Value
|
Improve this Doc
View Source
netId
The unique network Id of this object (unique at runtime).
Declaration
public uint netId { get; }
Property Value
|
Improve this Doc
View Source
netIdentity
Returns the NetworkIdentity of this object
Declaration
public NetworkIdentity netIdentity { get; }
Property Value
|
Improve this Doc
View Source
syncVarDirtyBits
Declaration
protected ulong syncVarDirtyBits { get; }
Property Value
Methods
|
Improve this Doc
View Source
ClearAllDirtyBits()
Clears all the dirty bits that were set by SetDirtyBits()
Declaration
public void ClearAllDirtyBits()
|
Improve this Doc
View Source
DeserializeSyncVars(NetworkReader, Boolean)
Declaration
protected virtual void DeserializeSyncVars(NetworkReader reader, bool initialState)
Parameters
|
Improve this Doc
View Source
GeneratedSyncVarDeserialize_GameObject(ref GameObject, Action<GameObject, GameObject>, NetworkReader, ref UInt32)
Declaration
public void GeneratedSyncVarDeserialize_GameObject(ref GameObject field, Action<GameObject, GameObject> OnChanged, NetworkReader reader, ref uint netIdField)
Parameters
Type |
Name |
Description |
GameObject |
field |
|
Action<GameObject, GameObject> |
OnChanged |
|
NetworkReader |
reader |
|
UInt32 |
netIdField |
|
|
Improve this Doc
View Source
GeneratedSyncVarDeserialize_NetworkBehaviour<T>(ref T, Action<T, T>, NetworkReader, ref NetworkBehaviour.NetworkBehaviourSyncVar)
Declaration
public void GeneratedSyncVarDeserialize_NetworkBehaviour<T>(ref T field, Action<T, T> OnChanged, NetworkReader reader, ref NetworkBehaviour.NetworkBehaviourSyncVar netIdField)
where T : NetworkBehaviour
Parameters
Type Parameters
|
Improve this Doc
View Source
GeneratedSyncVarDeserialize_NetworkIdentity(ref NetworkIdentity, Action<NetworkIdentity, NetworkIdentity>, NetworkReader, ref UInt32)
Declaration
public void GeneratedSyncVarDeserialize_NetworkIdentity(ref NetworkIdentity field, Action<NetworkIdentity, NetworkIdentity> OnChanged, NetworkReader reader, ref uint netIdField)
Parameters
|
Improve this Doc
View Source
GeneratedSyncVarDeserialize<T>(ref T, Action<T, T>, T)
Declaration
public void GeneratedSyncVarDeserialize<T>(ref T field, Action<T, T> OnChanged, T value)
Parameters
Type |
Name |
Description |
T |
field |
|
Action<T, T> |
OnChanged |
|
T |
value |
|
Type Parameters
|
Improve this Doc
View Source
GeneratedSyncVarSetter_GameObject(GameObject, ref GameObject, UInt64, Action<GameObject, GameObject>, ref UInt32)
Declaration
public void GeneratedSyncVarSetter_GameObject(GameObject value, ref GameObject field, ulong dirtyBit, Action<GameObject, GameObject> OnChanged, ref uint netIdField)
Parameters
Type |
Name |
Description |
GameObject |
value |
|
GameObject |
field |
|
UInt64 |
dirtyBit |
|
Action<GameObject, GameObject> |
OnChanged |
|
UInt32 |
netIdField |
|
|
Improve this Doc
View Source
GeneratedSyncVarSetter_NetworkBehaviour<T>(T, ref T, UInt64, Action<T, T>, ref NetworkBehaviour.NetworkBehaviourSyncVar)
Declaration
public void GeneratedSyncVarSetter_NetworkBehaviour<T>(T value, ref T field, ulong dirtyBit, Action<T, T> OnChanged, ref NetworkBehaviour.NetworkBehaviourSyncVar netIdField)
where T : NetworkBehaviour
Parameters
Type Parameters
|
Improve this Doc
View Source
GeneratedSyncVarSetter_NetworkIdentity(NetworkIdentity, ref NetworkIdentity, UInt64, Action<NetworkIdentity, NetworkIdentity>, ref UInt32)
Declaration
public void GeneratedSyncVarSetter_NetworkIdentity(NetworkIdentity value, ref NetworkIdentity field, ulong dirtyBit, Action<NetworkIdentity, NetworkIdentity> OnChanged, ref uint netIdField)
Parameters
|
Improve this Doc
View Source
GeneratedSyncVarSetter<T>(T, ref T, UInt64, Action<T, T>)
Declaration
public void GeneratedSyncVarSetter<T>(T value, ref T field, ulong dirtyBit, Action<T, T> OnChanged)
Parameters
Type |
Name |
Description |
T |
value |
|
T |
field |
|
UInt64 |
dirtyBit |
|
Action<T, T> |
OnChanged |
|
Type Parameters
|
Improve this Doc
View Source
GetSyncVarGameObject(UInt32, ref GameObject)
Declaration
protected GameObject GetSyncVarGameObject(uint netId, ref GameObject gameObjectField)
Parameters
Type |
Name |
Description |
UInt32 |
netId |
|
GameObject |
gameObjectField |
|
Returns
Type |
Description |
GameObject |
|
|
Improve this Doc
View Source
GetSyncVarHookGuard(UInt64)
Declaration
protected bool GetSyncVarHookGuard(ulong dirtyBit)
Parameters
Type |
Name |
Description |
UInt64 |
dirtyBit |
|
Returns
|
Improve this Doc
View Source
GetSyncVarNetworkBehaviour<T>(NetworkBehaviour.NetworkBehaviourSyncVar, ref T)
Declaration
protected T GetSyncVarNetworkBehaviour<T>(NetworkBehaviour.NetworkBehaviourSyncVar syncNetBehaviour, ref T behaviourField)
where T : NetworkBehaviour
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
GetSyncVarNetworkIdentity(UInt32, ref NetworkIdentity)
Declaration
protected NetworkIdentity GetSyncVarNetworkIdentity(uint netId, ref NetworkIdentity identityField)
Parameters
Returns
|
Improve this Doc
View Source
InitSyncObject(SyncObject)
Declaration
protected void InitSyncObject(SyncObject syncObject)
Parameters
|
Improve this Doc
View Source
IsDirty()
Declaration
Returns
|
Improve this Doc
View Source
OnDeserialize(NetworkReader, Boolean)
Override to do custom deserialization (instead of SyncVars/SyncLists). Use OnSerialize too.
Declaration
public virtual void OnDeserialize(NetworkReader reader, bool initialState)
Parameters
|
Improve this Doc
View Source
OnSerialize(NetworkWriter, Boolean)
Override to do custom serialization (instead of SyncVars/SyncLists). Use OnDeserialize too.
Declaration
public virtual bool OnSerialize(NetworkWriter writer, bool initialState)
Parameters
Returns
|
Improve this Doc
View Source
OnStartAuthority()
Like Start(), but only called for objects the client has authority over.
Declaration
public virtual void OnStartAuthority()
|
Improve this Doc
View Source
OnStartClient()
Like Start(), but only called on client and host.
Declaration
public virtual void OnStartClient()
|
Improve this Doc
View Source
OnStartLocalPlayer()
Like Start(), but only called on client and host for the local player object.
Declaration
public virtual void OnStartLocalPlayer()
|
Improve this Doc
View Source
OnStartServer()
Like Start(), but only called on server and host.
Declaration
public virtual void OnStartServer()
|
Improve this Doc
View Source
OnStopAuthority()
Stop event, only called for objects the client has authority over.
Declaration
public virtual void OnStopAuthority()
|
Improve this Doc
View Source
OnStopClient()
Stop event, only called on client and host.
Declaration
public virtual void OnStopClient()
|
Improve this Doc
View Source
OnStopLocalPlayer()
Stop event, but only called on client and host for the local player object.
Declaration
public virtual void OnStopLocalPlayer()
|
Improve this Doc
View Source
OnStopServer()
Stop event, only called on server and host.
Declaration
public virtual void OnStopServer()
|
Improve this Doc
View Source
SendCommandInternal(String, NetworkWriter, Int32, Boolean)
Declaration
protected void SendCommandInternal(string functionFullName, NetworkWriter writer, int channelId, bool requiresAuthority = true)
Parameters
|
Improve this Doc
View Source
SendRPCInternal(String, NetworkWriter, Int32, Boolean)
Declaration
protected void SendRPCInternal(string functionFullName, NetworkWriter writer, int channelId, bool includeOwner)
Parameters
|
Improve this Doc
View Source
SendTargetRPCInternal(NetworkConnection, String, NetworkWriter, Int32)
Declaration
protected void SendTargetRPCInternal(NetworkConnection conn, string functionFullName, NetworkWriter writer, int channelId)
Parameters
|
Improve this Doc
View Source
SerializeObjectsAll(NetworkWriter)
Declaration
public bool SerializeObjectsAll(NetworkWriter writer)
Parameters
Returns
|
Improve this Doc
View Source
SerializeObjectsDelta(NetworkWriter)
Declaration
public bool SerializeObjectsDelta(NetworkWriter writer)
Parameters
Returns
|
Improve this Doc
View Source
SerializeSyncVars(NetworkWriter, Boolean)
Declaration
protected virtual bool SerializeSyncVars(NetworkWriter writer, bool initialState)
Parameters
Returns
|
Improve this Doc
View Source
SetSyncVar<T>(T, ref T, UInt64)
Declaration
protected void SetSyncVar<T>(T value, ref T fieldValue, ulong dirtyBit)
Parameters
Type |
Name |
Description |
T |
value |
|
T |
fieldValue |
|
UInt64 |
dirtyBit |
|
Type Parameters
|
Improve this Doc
View Source
SetSyncVarDirtyBit(UInt64)
Set as dirty so that it's synced to clients again.
Declaration
public void SetSyncVarDirtyBit(ulong dirtyBit)
Parameters
Type |
Name |
Description |
UInt64 |
dirtyBit |
|
|
Improve this Doc
View Source
SetSyncVarGameObject(GameObject, ref GameObject, UInt64, ref UInt32)
Declaration
protected void SetSyncVarGameObject(GameObject newGameObject, ref GameObject gameObjectField, ulong dirtyBit, ref uint netIdField)
Parameters
Type |
Name |
Description |
GameObject |
newGameObject |
|
GameObject |
gameObjectField |
|
UInt64 |
dirtyBit |
|
UInt32 |
netIdField |
|
|
Improve this Doc
View Source
SetSyncVarHookGuard(UInt64, Boolean)
Declaration
protected void SetSyncVarHookGuard(ulong dirtyBit, bool value)
Parameters
|
Improve this Doc
View Source
SetSyncVarNetworkBehaviour<T>(T, ref T, UInt64, ref NetworkBehaviour.NetworkBehaviourSyncVar)
Declaration
protected void SetSyncVarNetworkBehaviour<T>(T newBehaviour, ref T behaviourField, ulong dirtyBit, ref NetworkBehaviour.NetworkBehaviourSyncVar syncField)
where T : NetworkBehaviour
Parameters
Type Parameters
|
Improve this Doc
View Source
SetSyncVarNetworkIdentity(NetworkIdentity, ref NetworkIdentity, UInt64, ref UInt32)
Declaration
protected void SetSyncVarNetworkIdentity(NetworkIdentity newIdentity, ref NetworkIdentity identityField, ulong dirtyBit, ref uint netIdField)
Parameters
|
Improve this Doc
View Source
SyncVarEqual<T>(T, ref T)
Declaration
protected static bool SyncVarEqual<T>(T value, ref T fieldValue)
Parameters
Type |
Name |
Description |
T |
value |
|
T |
fieldValue |
|
Returns
Type Parameters
|
Improve this Doc
View Source
SyncVarGameObjectEqual(GameObject, UInt32)
Declaration
public static bool SyncVarGameObjectEqual(GameObject newGameObject, uint netIdField)
Parameters
Type |
Name |
Description |
GameObject |
newGameObject |
|
UInt32 |
netIdField |
|
Returns
|
Improve this Doc
View Source
SyncVarNetworkBehaviourEqual<T>(T, NetworkBehaviour.NetworkBehaviourSyncVar)
Declaration
protected static bool SyncVarNetworkBehaviourEqual<T>(T newBehaviour, NetworkBehaviour.NetworkBehaviourSyncVar syncField)
where T : NetworkBehaviour
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
SyncVarNetworkIdentityEqual(NetworkIdentity, UInt32)
Declaration
public static bool SyncVarNetworkIdentityEqual(NetworkIdentity newIdentity, uint netIdField)
Parameters
Returns