update: 更新广告Banner操作的预处理逻辑 (广告未初始化前)

hotfix/v1.0.12.2
胡宇飞 2024-06-05 17:48:01 +08:00
parent 529e2ddeda
commit 1b97f8ec03
1 changed files with 27 additions and 3 deletions

View File

@ -268,6 +268,7 @@ namespace Guru
private static bool _initAdsCompleted = false;
private static bool _isBannerVisible = false;
public static bool IsAdsReady => _initAdsCompleted;
private static int _preBannerAction = 0;
public static AdsInitSpec GetDefaultAdsSpec()
{
@ -347,6 +348,21 @@ namespace Guru
private static void OnAdsInitComplete()
{
_initAdsCompleted = true;
if (_adInitSpec != null && _adInitSpec.loadBanner)
{
// 预制动作处理
if (_preBannerAction == 1)
{
_preBannerAction = 0;
ShowBanner();
}
else if (_preBannerAction == -1)
{
_preBannerAction = 0;
HideBanner();
}
}
Callbacks.Ads._onAdsInitComplete?.Invoke();
}
@ -354,7 +370,7 @@ namespace Guru
{
if (!IsAdsReady)
{
LogE("Ads is not ready. Call <GuruSDk.StartAdService> first.");
LogW("[SDK] Ads is not ready. Call <GuruSDk.StartAdService> first.");
return false;
}
return true;
@ -366,7 +382,11 @@ namespace Guru
/// <param name="placement"></param>
public static void ShowBanner(string placement = "")
{
if (!CheckAdsReady()) return;
if (!CheckAdsReady())
{
_preBannerAction = 1;
return;
}
ADService.Instance.ShowBanner(placement);
}
@ -391,7 +411,11 @@ namespace Guru
/// </summary>
public static void HideBanner()
{
if (!CheckAdsReady()) return;
if (!CheckAdsReady())
{
_preBannerAction = -1;
return;
}
ADService.Instance.HideBanner();
}