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(); }