Check if any component is dirty before serializing stuff (#135)

This commit is contained in:
Paul Pacheco 2018-12-04 04:11:55 -06:00 committed by vis2k
parent 15a5271553
commit 3515aff816

View File

@ -653,6 +653,8 @@ 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()
{
if (m_NetworkBehaviours.Any(comp => comp.IsDirty()))
{ {
// serialize all the dirty components and send (if any were dirty) // serialize all the dirty components and send (if any were dirty)
NetworkWriter writer = new NetworkWriter(); NetworkWriter writer = new NetworkWriter();
@ -666,6 +668,7 @@ internal void UNetUpdate()
NetworkServer.SendToReady(gameObject, (short)MsgType.UpdateVars, message); NetworkServer.SendToReady(gameObject, (short)MsgType.UpdateVars, message);
} }
} }
}
internal void OnUpdateVars(NetworkReader reader, bool initialState) internal void OnUpdateVars(NetworkReader reader, bool initialState)
{ {