This commit is contained in:
Savya Bikram Shah
2026-05-29 20:58:40 +05:45
parent 3e5ff544bf
commit 113b82bd46
7 changed files with 27 additions and 17 deletions

View File

@@ -89,6 +89,7 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
private void OnDrawingSelected(DrawingSelectedSignal signal)
{
if (_navigatingToGameplay) return;
_navigatingToGameplay = true;
HandleSelectionAsync(signal.TemplateId).Forget();
}
@@ -97,9 +98,11 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
{
var ct = _scopeCts?.Token ?? CancellationToken.None;
_loadingScreen.Show();
_loadingScreen.SetProgress(0f);
await ShowRewardedAdAsync(ct);
_loadingScreen.Show();
var progress = new Progress<float>(p => _loadingScreen.SetProgress(p * 0.5f));
var mappedProgress = new Progress<float>(p => _loadingScreen.SetProgress(0.5f + p * 0.25f));
await _progression.SetLastOpenedAsync(templateId);
@@ -110,15 +113,24 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
private async UniTask ShowRewardedAdAsync(CancellationToken ct)
{
const int InitTimeoutMs = 4000;
try
{
if (!_ads.IsInitialized) await _ads.InitializeAsync(ct);
if (!_ads.IsInitialized)
{
using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(ct);
timeoutCts.CancelAfter(InitTimeoutMs);
await _ads.InitializeAsync(timeoutCts.Token);
}
if (!_ads.IsReady(AdFormat.Rewarded)) return;
await _ads.ShowAsync(AdFormat.Rewarded, ct);
}
catch (OperationCanceledException) { }
catch (Exception ex)
{
UnityEngine.Debug.LogWarning($"[ColorbookFlow] Rewarded ad failed: {ex.Message}");
UnityEngine.Debug.LogWarning($"[ColorbookFlow] Rewarded ad skipped: {ex.Message}");
}
}