rewareded ux fix
This commit is contained in:
@@ -83,7 +83,10 @@ namespace Darkmatter.Features.SaveGate.Systems
|
||||
_overlay.OnWatch -= OnWatch;
|
||||
_overlay.OnCancel -= OnCancel;
|
||||
reg.Dispose();
|
||||
_overlay.HidePrompt();
|
||||
// On Watch, keep the prompt up with both buttons locked while the ad loads;
|
||||
// TryShowRewardedAsync hides it once the ad is ready or fails. Cancel/cancellation hide now.
|
||||
if (result && !canceled) _overlay.SetPromptButtonsInteractable(false);
|
||||
else _overlay.HidePrompt();
|
||||
if (canceled) tcs.TrySetCanceled(ct);
|
||||
else tcs.TrySetResult(result);
|
||||
}
|
||||
@@ -105,16 +108,18 @@ namespace Darkmatter.Features.SaveGate.Systems
|
||||
try
|
||||
{
|
||||
if (!_ads.IsInitialized) await _ads.InitializeAsync(ct);
|
||||
if (!_ads.IsReady(AdFormat.Rewarded) && !await _ads.LoadAsync(AdFormat.Rewarded, ct))
|
||||
return _config.SaveWithoutAdOnFailure;
|
||||
var ready = _ads.IsReady(AdFormat.Rewarded) || await _ads.LoadAsync(AdFormat.Rewarded, ct);
|
||||
_overlay.HidePrompt(); // ad loaded or failed to load — now hide the prompt
|
||||
if (!ready) return _config.SaveWithoutAdOnFailure;
|
||||
|
||||
var result = await _ads.ShowAsync(AdFormat.Rewarded, ct);
|
||||
if (result.Rewarded) return true;
|
||||
return result.Shown ? false : _config.SaveWithoutAdOnFailure;
|
||||
}
|
||||
catch (OperationCanceledException) { throw; }
|
||||
catch (OperationCanceledException) { _overlay.HidePrompt(); throw; }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_overlay.HidePrompt();
|
||||
UnityEngine.Debug.LogWarning($"[SaveGate] Rewarded ad gate failed: {ex.Message}");
|
||||
return _config.SaveWithoutAdOnFailure;
|
||||
}
|
||||
|
||||
@@ -50,9 +50,18 @@ namespace Darkmatter.Features.SaveGate.UI
|
||||
public void ShowPrompt()
|
||||
{
|
||||
if (successPanel != null) successPanel.SetActive(false);
|
||||
SetPromptButtonsInteractable(true);
|
||||
if (promptPanel != null) promptPanel.SetActive(true);
|
||||
}
|
||||
|
||||
// Keep the prompt visible but lock both buttons — used while the rewarded ad loads
|
||||
// after the child taps Watch, so the UI doesn't disappear during the wait.
|
||||
public void SetPromptButtonsInteractable(bool interactable)
|
||||
{
|
||||
if (watchButton != null) watchButton.interactable = interactable;
|
||||
if (cancelButton != null) cancelButton.interactable = interactable;
|
||||
}
|
||||
|
||||
public void HidePrompt()
|
||||
{
|
||||
if (promptPanel != null) promptPanel.SetActive(false);
|
||||
|
||||
Reference in New Issue
Block a user