mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
refactor: make UIService Disposable, and sure UIBootstrapper disposes it OnDisable.
This commit is contained in:
committed by
alexiscatnip
parent
79b843b699
commit
b49787d19f
@@ -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<UIService>();
|
||||
}
|
||||
_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<UIService>(uisrv);
|
||||
ServiceLocator.Instance.Register<UIService>(_uisrv);
|
||||
|
||||
uisrv.MapFacade = references.mapUI;
|
||||
_uisrv.MapFacade = references.mapUI;
|
||||
|
||||
//3. start the chat window right.
|
||||
references.chatPresenter.Initialise();
|
||||
|
||||
@@ -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<LoginProgressEventArgs>(netcom_ClientLoginStatus);
|
||||
netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
|
||||
netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
|
||||
|
||||
Reference in New Issue
Block a user