diff --git a/Assets/Raindrop/Bootstrap/UIBootstrapper.cs b/Assets/Raindrop/Bootstrap/UIBootstrapper.cs index 6a4e3fb..011c89c 100644 --- a/Assets/Raindrop/Bootstrap/UIBootstrapper.cs +++ b/Assets/Raindrop/Bootstrap/UIBootstrapper.cs @@ -15,6 +15,9 @@ namespace Raindrop.Bootstrap private RaindropNetcom netcom => instance.Netcom; [SerializeField] public References references; + + private UIService _uisrv; + // bootstraps the UI. private void Start() // 1. finds all the canvasmanager and modal managers. @@ -34,6 +37,7 @@ namespace Raindrop.Bootstrap { ServiceLocator.Instance.Unregister(); } + _uisrv.Dispose(); } @@ -58,15 +62,15 @@ namespace Raindrop.Bootstrap Debug.LogError("loadingscreen not present"); references.ll.Init(); - var uisrv = new UIService( + _uisrv = new UIService( instance, references.sm, references.mm, references.ll, references.chatPresenter); - ServiceLocator.Instance.Register(uisrv); + ServiceLocator.Instance.Register(_uisrv); - uisrv.MapFacade = references.mapUI; + _uisrv.MapFacade = references.mapUI; //3. start the chat window right. references.chatPresenter.Initialise(); diff --git a/Assets/Raindrop/Services/UIService.cs b/Assets/Raindrop/Services/UIService.cs index 78b018e..6799422 100644 --- a/Assets/Raindrop/Services/UIService.cs +++ b/Assets/Raindrop/Services/UIService.cs @@ -9,7 +9,7 @@ using UnityEngine; namespace Raindrop.Services { - public class UIService : IGameService + public class UIService : IGameService, IDisposable { //UI is a service. it will always be available. // presenters themselves provide the logic of ui-traversal. @@ -66,8 +66,10 @@ namespace Raindrop.Services initialise(); } - ~UIService() + public void Dispose() { + _loadingController?.Dispose(); + netcom.ClientLoginStatus -= new EventHandler(netcom_ClientLoginStatus); netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut); netcom.ClientDisconnected -= new EventHandler(netcom_ClientDisconnected);