Skip to content

Commit

Permalink
fix: fixing null ref in SyncPositionBehaviour
Browse files Browse the repository at this point in the history
adding extra null checks to stop null check incase order of events is different
  • Loading branch information
James-Frowen authored Jun 12, 2023
1 parent 29b67b3 commit 69ba59d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Assets/NetworkPositionSync/Runtime/SyncPositionBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,20 @@ public void OnStartServer()
public void OnStopClient()
{
// dont add twice in host mode
if (IsServer) return;
_system.Behaviours.RemoveBehaviour(this);
if (IsServer)
return;

// null check incase IsServer is set to false before OnStopClient is called
if (_system != null)
_system.Behaviours.RemoveBehaviour(this);
_system = null;
}

public void OnStopServer()
{
_system.Behaviours.RemoveBehaviour(this);
// null check incase OnStopClient is called first
if (_system !=null)
_system.Behaviours.RemoveBehaviour(this);
_system = null;
}
#endregion
Expand Down

0 comments on commit 69ba59d

Please sign in to comment.