Skip to content

Commit

Permalink
fix: do not accumulate changes if there are no observers fixes #963 (#…
Browse files Browse the repository at this point in the history
…964)

* fix: do not accumulate changes if there are no observers #963

* Update NetworkIdentity.cs
  • Loading branch information
paulpach authored and miwarnec committed Jul 17, 2019
1 parent 310556c commit 64a0468
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Assets/Mirror/Runtime/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,16 @@ internal void Reset()
// invoked by NetworkServer during Update()
internal void MirrorUpdate()
{
// SendToReady sends to all observers. no need to serialize if we
// don't have any.
if (observers == null || observers.Count == 0)
{
// if we have no observers, then flush all objects
// (fixes https://github.com/vis2k/Mirror/issues/963)
foreach (NetworkBehaviour comp in networkBehavioursCache)
{
comp.ClearAllDirtyBits();
}
return;
}

NetworkWriter writer = NetworkWriterPool.GetWriter();
// serialize all the dirty components and send (if any were dirty)
Expand Down

0 comments on commit 64a0468

Please sign in to comment.