diff --git a/Assets/Raindrop/Bootstrap/UIBootstrapper.cs b/Assets/Raindrop/Bootstrap/UIBootstrapper.cs index 9726833..5635468 100644 --- a/Assets/Raindrop/Bootstrap/UIBootstrapper.cs +++ b/Assets/Raindrop/Bootstrap/UIBootstrapper.cs @@ -27,7 +27,7 @@ namespace Raindrop.Bootstrap InitialiseUIVariant(); } - private void OnDestroy() + private void OnDisable() { if (ServiceLocator.Instance.IsRegistered()) { diff --git a/Assets/Raindrop/Services/UIService.cs b/Assets/Raindrop/Services/UIService.cs index 6799422..438080b 100644 --- a/Assets/Raindrop/Services/UIService.cs +++ b/Assets/Raindrop/Services/UIService.cs @@ -69,11 +69,14 @@ namespace Raindrop.Services public void Dispose() { _loadingController?.Dispose(); - - netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); - netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); - netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); - instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); + + if (netcom != null) + { + netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); + netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); + netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected); + instance.Names.NameUpdated -= new EventHandler(Names_NameUpdated); + } UnregisterClientEvents(client); } diff --git a/Assets/Raindrop/UI/Map/Map_SceneHierachy/MapScenePresenter.cs b/Assets/Raindrop/UI/Map/Map_SceneHierachy/MapScenePresenter.cs index c3c6780..51dbbeb 100644 --- a/Assets/Raindrop/UI/Map/Map_SceneHierachy/MapScenePresenter.cs +++ b/Assets/Raindrop/UI/Map/Map_SceneHierachy/MapScenePresenter.cs @@ -104,7 +104,7 @@ namespace Raindrop.UI.map.Map_SceneHierachy Client.Grid.GridRegion -= new EventHandler(Grid_GridRegion); Client.Grid.GridLayer -= new EventHandler(Grid_GridLayer); - if (Instance == null) return; + if (Instance?.Netcom == null) return; Instance.Netcom.ClientConnected -= NetcomOnClientConnected; Instance.Netcom.ClientDisconnected -= NetcomOnClientDisconnected; }