mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Check if any component is dirty before serializing stuff (#135)
This commit is contained in:
parent
15a5271553
commit
3515aff816
@ -654,16 +654,19 @@ internal void HandleRPC(int componentIndex, int cmdHash, NetworkReader reader)
|
|||||||
// invoked by unity runtime immediately after the regular "Update()" function.
|
// invoked by unity runtime immediately after the regular "Update()" function.
|
||||||
internal void UNetUpdate()
|
internal void UNetUpdate()
|
||||||
{
|
{
|
||||||
// serialize all the dirty components and send (if any were dirty)
|
if (m_NetworkBehaviours.Any(comp => comp.IsDirty()))
|
||||||
NetworkWriter writer = new NetworkWriter();
|
|
||||||
if (OnSerializeAllSafely(m_NetworkBehaviours, writer, false))
|
|
||||||
{
|
{
|
||||||
// construct message and send
|
// serialize all the dirty components and send (if any were dirty)
|
||||||
UpdateVarsMessage message = new UpdateVarsMessage();
|
NetworkWriter writer = new NetworkWriter();
|
||||||
message.netId = netId;
|
if (OnSerializeAllSafely(m_NetworkBehaviours, writer, false))
|
||||||
message.payload = writer.ToArray();
|
{
|
||||||
|
// construct message and send
|
||||||
|
UpdateVarsMessage message = new UpdateVarsMessage();
|
||||||
|
message.netId = netId;
|
||||||
|
message.payload = writer.ToArray();
|
||||||
|
|
||||||
NetworkServer.SendToReady(gameObject, (short)MsgType.UpdateVars, message);
|
NetworkServer.SendToReady(gameObject, (short)MsgType.UpdateVars, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user