rewareded ux fix
This commit is contained in:
@@ -83,7 +83,10 @@ namespace Darkmatter.Features.SaveGate.Systems
|
|||||||
_overlay.OnWatch -= OnWatch;
|
_overlay.OnWatch -= OnWatch;
|
||||||
_overlay.OnCancel -= OnCancel;
|
_overlay.OnCancel -= OnCancel;
|
||||||
reg.Dispose();
|
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);
|
if (canceled) tcs.TrySetCanceled(ct);
|
||||||
else tcs.TrySetResult(result);
|
else tcs.TrySetResult(result);
|
||||||
}
|
}
|
||||||
@@ -105,16 +108,18 @@ namespace Darkmatter.Features.SaveGate.Systems
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_ads.IsInitialized) await _ads.InitializeAsync(ct);
|
if (!_ads.IsInitialized) await _ads.InitializeAsync(ct);
|
||||||
if (!_ads.IsReady(AdFormat.Rewarded) && !await _ads.LoadAsync(AdFormat.Rewarded, ct))
|
var ready = _ads.IsReady(AdFormat.Rewarded) || await _ads.LoadAsync(AdFormat.Rewarded, ct);
|
||||||
return _config.SaveWithoutAdOnFailure;
|
_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);
|
var result = await _ads.ShowAsync(AdFormat.Rewarded, ct);
|
||||||
if (result.Rewarded) return true;
|
if (result.Rewarded) return true;
|
||||||
return result.Shown ? false : _config.SaveWithoutAdOnFailure;
|
return result.Shown ? false : _config.SaveWithoutAdOnFailure;
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException) { throw; }
|
catch (OperationCanceledException) { _overlay.HidePrompt(); throw; }
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
_overlay.HidePrompt();
|
||||||
UnityEngine.Debug.LogWarning($"[SaveGate] Rewarded ad gate failed: {ex.Message}");
|
UnityEngine.Debug.LogWarning($"[SaveGate] Rewarded ad gate failed: {ex.Message}");
|
||||||
return _config.SaveWithoutAdOnFailure;
|
return _config.SaveWithoutAdOnFailure;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,18 @@ namespace Darkmatter.Features.SaveGate.UI
|
|||||||
public void ShowPrompt()
|
public void ShowPrompt()
|
||||||
{
|
{
|
||||||
if (successPanel != null) successPanel.SetActive(false);
|
if (successPanel != null) successPanel.SetActive(false);
|
||||||
|
SetPromptButtonsInteractable(true);
|
||||||
if (promptPanel != null) promptPanel.SetActive(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()
|
public void HidePrompt()
|
||||||
{
|
{
|
||||||
if (promptPanel != null) promptPanel.SetActive(false);
|
if (promptPanel != null) promptPanel.SetActive(false);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user