fix: Added clientStarted check to OnStopClient

- fixes: #3245
This commit is contained in:
MrGadget1024 2022-12-14 23:51:08 -05:00
parent 3e3a1cbb44
commit 461ce27908

View File

@ -674,8 +674,8 @@ internal void OnStopServer()
bool clientStarted;
internal void OnStartClient()
{
if (clientStarted)
return;
if (clientStarted) return;
clientStarted = true;
// Debug.Log($"OnStartClient {gameObject} netId:{netId}");
@ -700,6 +700,10 @@ internal void OnStartClient()
internal void OnStopClient()
{
// In case this object was destroyed already don't call
// OnStopClient if OnStartClient hasn't been called.
if (!clientStarted) return;
foreach (NetworkBehaviour comp in NetworkBehaviours)
{
// an exception in OnStopClient should be caught, so that