62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
#endif
|
|
|
|
namespace DanieleMarotta.RiversongCodeShowcase
|
|
{
|
|
public class PausePopupUIController : UIControllerSystem<PausePopupUIView>, IDisposable
|
|
{
|
|
[InjectService]
|
|
private ICancelAction _cancelAction;
|
|
|
|
public PausePopupUIController(IServiceLocator serviceLocator) : base(serviceLocator)
|
|
{
|
|
}
|
|
|
|
protected override PausePopupUIView View => UIRoot.GetView<PausePopupUIView>();
|
|
|
|
public override async UniTask InitializeAsync()
|
|
{
|
|
await base.InitializeAsync();
|
|
|
|
View.Show(false);
|
|
|
|
View.FeedbackButtonClick += OnFeedbackButtonClick;
|
|
View.QuitButtonClick += OnQuitButtonClick;
|
|
|
|
_cancelAction.AddHandler(
|
|
(int)CancelActions.PauseMenu,
|
|
cancelActionType =>
|
|
{
|
|
if (cancelActionType != CancelActionType.EscapeKey) return false;
|
|
|
|
View.Toggle(true);
|
|
|
|
return true;
|
|
});
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
View.FeedbackButtonClick -= OnFeedbackButtonClick;
|
|
View.QuitButtonClick -= OnQuitButtonClick;
|
|
}
|
|
|
|
private void OnFeedbackButtonClick()
|
|
{
|
|
Application.OpenURL(AppLinks.DemoFeedbackUrl);
|
|
}
|
|
|
|
private void OnQuitButtonClick()
|
|
{
|
|
#if UNITY_EDITOR
|
|
EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
}
|
|
}
|
|
} |