Доработка отмены процесса выхода по таймеру

This commit is contained in:
Сергей Бондарь 2026-06-09 16:11:35 +03:00
parent 46a8ad62a0
commit ac01ee34dc

View File

@ -46,6 +46,7 @@ public class AwardsController : MonoBehaviour
private bool polling = false;
private CancellationTokenSource timerCts;
async void Start()
{
if (!BootstrapperState.MainBootstraped)
@ -79,8 +80,11 @@ public class AwardsController : MonoBehaviour
polling = true;
//Запустить таймер
timerCts = new CancellationTokenSource();
ShowTimer();
WaitTimeoutNExit(this.GetCancellationTokenOnDestroy()).Forget();
WaitTimeoutNExit(timerCts.Token).Forget();
}
private void Update()
@ -88,6 +92,7 @@ public class AwardsController : MonoBehaviour
if (!polling) return;
if (In.GetButtonDown(InSignal.DownRight))
{
CancelToken();
SceneLoader.LoadScene(menuSceneName);
}
if (In.GetButtonDown(InSignal.UpRight))
@ -97,11 +102,19 @@ public class AwardsController : MonoBehaviour
{
CountersSystem.Increment(CountersSystem.CounterType.TotalStarts);
CountersSystem.Increment(CountersSystem.CounterType.StartsFromRevenge);
CancelToken();
SceneLoader.LoadScene(gameplaySceneName);
}
}
}
private void CancelToken()
{
timerCts?.Cancel();
timerCts?.Dispose();
timerCts = null;
}
private void Setup()
{
canvas.worldCamera = CamerasManager.Screen_Camera;
@ -175,6 +188,7 @@ public class AwardsController : MonoBehaviour
break;
}
}
Debug.Log("Таймер убит");
}
private async UniTask DisplayRankName()