From 1b97f8ec037e4ed0a49e44c3201de99f34ff7ba6 Mon Sep 17 00:00:00 2001 From: huyufei Date: Wed, 5 Jun 2024 17:48:01 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E5=B9=BF=E5=91=8AB?= =?UTF-8?q?anner=E6=93=8D=E4=BD=9C=E7=9A=84=E9=A2=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20=EF=BC=88=E5=B9=BF=E5=91=8A=E6=9C=AA?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=89=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Ads.cs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Ads.cs b/Runtime/Code/SDK/GuruSDK.Ads.cs index 0eac1a5..b583de2 100644 --- a/Runtime/Code/SDK/GuruSDK.Ads.cs +++ b/Runtime/Code/SDK/GuruSDK.Ads.cs @@ -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 first."); + LogW("[SDK] Ads is not ready. Call first."); return false; } return true; @@ -366,7 +382,11 @@ namespace Guru /// public static void ShowBanner(string placement = "") { - if (!CheckAdsReady()) return; + if (!CheckAdsReady()) + { + _preBannerAction = 1; + return; + } ADService.Instance.ShowBanner(placement); } @@ -391,7 +411,11 @@ namespace Guru /// public static void HideBanner() { - if (!CheckAdsReady()) return; + if (!CheckAdsReady()) + { + _preBannerAction = -1; + return; + } ADService.Instance.HideBanner(); }