From f258f0bb6877fbf6734f7df04bcdacf6fc45db33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Mon, 2 Apr 2018 16:51:16 +0200 Subject: [PATCH] Added null checks to NetworkedObject --- MLAPI/MonoBehaviours/Core/NetworkedObject.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MLAPI/MonoBehaviours/Core/NetworkedObject.cs b/MLAPI/MonoBehaviours/Core/NetworkedObject.cs index e488300..3805691 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkedObject.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkedObject.cs @@ -124,7 +124,8 @@ namespace MLAPI.MonoBehaviours.Core private void OnDestroy() { - SpawnManager.OnDestroyObject(NetworkId, false); + if (NetworkingManager.singleton != null) + SpawnManager.OnDestroyObject(NetworkId, false); } /// @@ -132,7 +133,8 @@ namespace MLAPI.MonoBehaviours.Core /// public void Spawn() { - SpawnManager.OnSpawnObject(this); + if (NetworkingManager.singleton != null) + SpawnManager.OnSpawnObject(this); } /// /// Spawns an object across the network with a given owner. Can only be called from server @@ -140,7 +142,8 @@ namespace MLAPI.MonoBehaviours.Core /// The clientId to own the object public void SpawnWithOwnership(int clientId) { - SpawnManager.OnSpawnObject(this, clientId); + if (NetworkingManager.singleton != null) + SpawnManager.OnSpawnObject(this, clientId); } /// /// Removes all ownership of an object from any client. Can only be called from server