C# 클래스 Mirror.NetworkBehaviour

상속: MonoBehaviour
파일 보기 프로젝트 열기: BatteryAcid/unity-custom-gamelift-server 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
syncObjects List

공개 메소드들

메소드 설명
ClearAllDirtyBits ( ) : void

This clears all the dirty bits that were set on this script by SetDirtyBits();

This is automatically invoked when an update is sent for this object, but can be called manually as well.

IsDirty ( ) : bool
OnDeserialize ( Mirror.NetworkReader reader, bool initialState ) : void

Virtual function to override to receive custom serialization data. The corresponding function to send serialization data is OnSerialize().

OnSerialize ( Mirror.NetworkWriter writer, bool initialState ) : bool

Virtual function to override to send custom serialization data. The corresponding function to send serialization data is OnDeserialize().

The initialState flag is useful to differentiate between the first time an object is serialized and when incremental updates can be sent. The first time an object is sent to a client, it must include a full state snapshot, but subsequent updates can save on bandwidth by including only incremental changes. Note that SyncVar hook functions are not called when initialState is true, only for incremental updates.

If a class has SyncVars, then an implementation of this function and OnDeserialize() are added automatically to the class. So a class that has SyncVars cannot also have custom serialization functions.

The OnSerialize function should return true to indicate that an update should be sent. If it returns true, then the dirty bits for that script are set to zero, if it returns false then the dirty bits are not changed. This allows multiple changes to a script to be accumulated over time and sent when the system is ready, instead of every frame.

OnStartAuthority ( ) : void

This is invoked on behaviours that have authority, based on context and NetworkIdentity.hasAuthority.

This is called after OnStartServer and before OnStartClient.

When AssignClientAuthority is called on the server, this will be called on the client that owns the object. When an object is spawned with NetworkServer.Spawn with a NetworkConnection parameter included, this will be called on the client that owns the object.

OnStartClient ( ) : void

Called on every NetworkBehaviour when it is activated on a client.

Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.

OnStartLocalPlayer ( ) : void

Called when the local player object has been set up.

This happens after OnStartClient(), as it is triggered by an ownership message from the server. This is an appropriate place to activate components or functionality that should only be active for the local player, such as cameras and input.

OnStartServer ( ) : void

This is invoked for NetworkBehaviour objects when they become active on the server.

This could be triggered by NetworkServer.Listen() for objects in the scene, or by NetworkServer.Spawn() for objects that are dynamically created.

This will be called for objects on a "host" as well as for object on a dedicated server.

OnStopAuthority ( ) : void

This is invoked on behaviours when authority is removed.

When NetworkIdentity.RemoveClientAuthority is called on the server, this will be called on the client that owns the object.

OnStopClient ( ) : void

This is invoked on clients when the server has caused this object to be destroyed.

This can be used as a hook to invoke effects or do client specific cleanup.

OnStopServer ( ) : void

Invoked on the server when the object is unspawned

Useful for saving object data in persistent storage

SerializeObjectsAll ( NetworkWriter writer ) : bool
SerializeObjectsDelta ( NetworkWriter writer ) : bool
SetDirtyBit ( ulong dirtyBit ) : void

Used to set the behaviour as dirty, so that a network update will be sent for the object. these are masks, not bit numbers, ie. 0x004 not 2

보호된 메소드들

메소드 설명
DeserializeSyncVars ( Mirror.NetworkReader reader, bool initialState ) : void
GetSyncVarGameObject ( uint netId, GameObject &gameObjectField ) : GameObject
GetSyncVarNetworkBehaviour ( NetworkBehaviourSyncVar syncNetBehaviour, &behaviourField ) : T
GetSyncVarNetworkIdentity ( uint netId, Mirror.NetworkIdentity &identityField ) : Mirror.NetworkIdentity
InitSyncObject ( Mirror.SyncObject syncObject ) : void
SendCommandInternal ( Type invokeClass, string cmdName, NetworkWriter writer, int channelId, bool ignoreAuthority = false ) : void
SendRPCInternal ( Type invokeClass, string rpcName, NetworkWriter writer, int channelId, bool excludeOwner ) : void
SendTargetRPCInternal ( NetworkConnection conn, Type invokeClass, string rpcName, NetworkWriter writer, int channelId ) : void
SerializeSyncVars ( NetworkWriter writer, bool initialState ) : bool
SetSyncVar ( value, &fieldValue, ulong dirtyBit ) : void
SetSyncVarGameObject ( GameObject newGameObject, GameObject &gameObjectField, ulong dirtyBit, uint &netIdField ) : void
SetSyncVarNetworkBehaviour ( newBehaviour, &behaviourField, ulong dirtyBit, NetworkBehaviourSyncVar &syncField ) : void
SetSyncVarNetworkIdentity ( NetworkIdentity newIdentity, NetworkIdentity &identityField, ulong dirtyBit, uint &netIdField ) : void
SyncVarEqual ( value, &fieldValue ) : bool
SyncVarGameObjectEqual ( GameObject newGameObject, uint netIdField ) : bool
SyncVarNetworkBehaviourEqual ( newBehaviour, NetworkBehaviourSyncVar syncField ) : bool
SyncVarNetworkIdentityEqual ( NetworkIdentity newIdentity, uint netIdField ) : bool
getSyncVarHookGuard ( ulong dirtyBit ) : bool
setSyncVarHookGuard ( ulong dirtyBit, bool value ) : void

비공개 메소드들

메소드 설명
AnySyncObjectDirty ( ) : bool
DeSerializeObjectsAll ( Mirror.NetworkReader reader ) : void
DeSerializeObjectsDelta ( Mirror.NetworkReader reader ) : void
DirtyObjectBits ( ) : ulong
ResetSyncObjects ( ) : void

메소드 상세

ClearAllDirtyBits() 공개 메소드

This clears all the dirty bits that were set on this script by SetDirtyBits();

This is automatically invoked when an update is sent for this object, but can be called manually as well.

public ClearAllDirtyBits ( ) : void
리턴 void

DeserializeSyncVars() 보호된 메소드

protected DeserializeSyncVars ( Mirror.NetworkReader reader, bool initialState ) : void
reader Mirror.NetworkReader
initialState bool
리턴 void

GetSyncVarGameObject() 보호된 메소드

protected GetSyncVarGameObject ( uint netId, GameObject &gameObjectField ) : GameObject
netId uint
gameObjectField GameObject
리턴 GameObject

GetSyncVarNetworkBehaviour() 보호된 메소드

protected GetSyncVarNetworkBehaviour ( NetworkBehaviourSyncVar syncNetBehaviour, &behaviourField ) : T
syncNetBehaviour NetworkBehaviourSyncVar
리턴 T

GetSyncVarNetworkIdentity() 보호된 메소드

protected GetSyncVarNetworkIdentity ( uint netId, Mirror.NetworkIdentity &identityField ) : Mirror.NetworkIdentity
netId uint
identityField Mirror.NetworkIdentity
리턴 Mirror.NetworkIdentity

InitSyncObject() 보호된 메소드

protected InitSyncObject ( Mirror.SyncObject syncObject ) : void
syncObject Mirror.SyncObject
리턴 void

IsDirty() 공개 메소드

public IsDirty ( ) : bool
리턴 bool

OnDeserialize() 공개 메소드

Virtual function to override to receive custom serialization data. The corresponding function to send serialization data is OnSerialize().
public OnDeserialize ( Mirror.NetworkReader reader, bool initialState ) : void
reader Mirror.NetworkReader Reader to read from the stream.
initialState bool True if being sent initial state.
리턴 void

OnSerialize() 공개 메소드

Virtual function to override to send custom serialization data. The corresponding function to send serialization data is OnDeserialize().

The initialState flag is useful to differentiate between the first time an object is serialized and when incremental updates can be sent. The first time an object is sent to a client, it must include a full state snapshot, but subsequent updates can save on bandwidth by including only incremental changes. Note that SyncVar hook functions are not called when initialState is true, only for incremental updates.

If a class has SyncVars, then an implementation of this function and OnDeserialize() are added automatically to the class. So a class that has SyncVars cannot also have custom serialization functions.

The OnSerialize function should return true to indicate that an update should be sent. If it returns true, then the dirty bits for that script are set to zero, if it returns false then the dirty bits are not changed. This allows multiple changes to a script to be accumulated over time and sent when the system is ready, instead of every frame.

public OnSerialize ( Mirror.NetworkWriter writer, bool initialState ) : bool
writer Mirror.NetworkWriter Writer to use to write to the stream.
initialState bool If this is being called to send initial state.
리턴 bool

OnStartAuthority() 공개 메소드

This is invoked on behaviours that have authority, based on context and NetworkIdentity.hasAuthority.

This is called after OnStartServer and before OnStartClient.

When AssignClientAuthority is called on the server, this will be called on the client that owns the object. When an object is spawned with NetworkServer.Spawn with a NetworkConnection parameter included, this will be called on the client that owns the object.

public OnStartAuthority ( ) : void
리턴 void

OnStartClient() 공개 메소드

Called on every NetworkBehaviour when it is activated on a client.

Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.

public OnStartClient ( ) : void
리턴 void

OnStartLocalPlayer() 공개 메소드

Called when the local player object has been set up.

This happens after OnStartClient(), as it is triggered by an ownership message from the server. This is an appropriate place to activate components or functionality that should only be active for the local player, such as cameras and input.

public OnStartLocalPlayer ( ) : void
리턴 void

OnStartServer() 공개 메소드

This is invoked for NetworkBehaviour objects when they become active on the server.

This could be triggered by NetworkServer.Listen() for objects in the scene, or by NetworkServer.Spawn() for objects that are dynamically created.

This will be called for objects on a "host" as well as for object on a dedicated server.

public OnStartServer ( ) : void
리턴 void

OnStopAuthority() 공개 메소드

This is invoked on behaviours when authority is removed.

When NetworkIdentity.RemoveClientAuthority is called on the server, this will be called on the client that owns the object.

public OnStopAuthority ( ) : void
리턴 void

OnStopClient() 공개 메소드

This is invoked on clients when the server has caused this object to be destroyed.

This can be used as a hook to invoke effects or do client specific cleanup.

public OnStopClient ( ) : void
리턴 void

OnStopServer() 공개 메소드

Invoked on the server when the object is unspawned

Useful for saving object data in persistent storage

public OnStopServer ( ) : void
리턴 void

SendCommandInternal() 보호된 메소드

protected SendCommandInternal ( Type invokeClass, string cmdName, NetworkWriter writer, int channelId, bool ignoreAuthority = false ) : void
invokeClass Type
cmdName string
writer NetworkWriter
channelId int
ignoreAuthority bool
리턴 void

SendRPCInternal() 보호된 메소드

protected SendRPCInternal ( Type invokeClass, string rpcName, NetworkWriter writer, int channelId, bool excludeOwner ) : void
invokeClass Type
rpcName string
writer NetworkWriter
channelId int
excludeOwner bool
리턴 void

SendTargetRPCInternal() 보호된 메소드

protected SendTargetRPCInternal ( NetworkConnection conn, Type invokeClass, string rpcName, NetworkWriter writer, int channelId ) : void
conn NetworkConnection
invokeClass Type
rpcName string
writer NetworkWriter
channelId int
리턴 void

SerializeObjectsAll() 공개 메소드

public SerializeObjectsAll ( NetworkWriter writer ) : bool
writer NetworkWriter
리턴 bool

SerializeObjectsDelta() 공개 메소드

public SerializeObjectsDelta ( NetworkWriter writer ) : bool
writer NetworkWriter
리턴 bool

SerializeSyncVars() 보호된 메소드

protected SerializeSyncVars ( NetworkWriter writer, bool initialState ) : bool
writer NetworkWriter
initialState bool
리턴 bool

SetDirtyBit() 공개 메소드

Used to set the behaviour as dirty, so that a network update will be sent for the object. these are masks, not bit numbers, ie. 0x004 not 2
public SetDirtyBit ( ulong dirtyBit ) : void
dirtyBit ulong Bit mask to set.
리턴 void

SetSyncVar() 보호된 메소드

protected SetSyncVar ( value, &fieldValue, ulong dirtyBit ) : void
dirtyBit ulong
리턴 void

SetSyncVarGameObject() 보호된 메소드

protected SetSyncVarGameObject ( GameObject newGameObject, GameObject &gameObjectField, ulong dirtyBit, uint &netIdField ) : void
newGameObject GameObject
gameObjectField GameObject
dirtyBit ulong
netIdField uint
리턴 void

SetSyncVarNetworkBehaviour() 보호된 메소드

protected SetSyncVarNetworkBehaviour ( newBehaviour, &behaviourField, ulong dirtyBit, NetworkBehaviourSyncVar &syncField ) : void
dirtyBit ulong
syncField NetworkBehaviourSyncVar
리턴 void

SetSyncVarNetworkIdentity() 보호된 메소드

protected SetSyncVarNetworkIdentity ( NetworkIdentity newIdentity, NetworkIdentity &identityField, ulong dirtyBit, uint &netIdField ) : void
newIdentity NetworkIdentity
identityField NetworkIdentity
dirtyBit ulong
netIdField uint
리턴 void

SyncVarEqual() 보호된 메소드

protected SyncVarEqual ( value, &fieldValue ) : bool
리턴 bool

SyncVarGameObjectEqual() 보호된 메소드

protected SyncVarGameObjectEqual ( GameObject newGameObject, uint netIdField ) : bool
newGameObject GameObject
netIdField uint
리턴 bool

SyncVarNetworkBehaviourEqual() 보호된 메소드

protected SyncVarNetworkBehaviourEqual ( newBehaviour, NetworkBehaviourSyncVar syncField ) : bool
syncField NetworkBehaviourSyncVar
리턴 bool

SyncVarNetworkIdentityEqual() 보호된 메소드

protected SyncVarNetworkIdentityEqual ( NetworkIdentity newIdentity, uint netIdField ) : bool
newIdentity NetworkIdentity
netIdField uint
리턴 bool

getSyncVarHookGuard() 보호된 메소드

protected getSyncVarHookGuard ( ulong dirtyBit ) : bool
dirtyBit ulong
리턴 bool

setSyncVarHookGuard() 보호된 메소드

protected setSyncVarHookGuard ( ulong dirtyBit, bool value ) : void
dirtyBit ulong
value bool
리턴 void

프로퍼티 상세

syncObjects 보호되어 있는 프로퍼티

objects that can synchronize themselves, such as synclists
protected List syncObjects
리턴 List