From 311b53ea5f896058d5ebc0e6abb33d9977771f40 Mon Sep 17 00:00:00 2001 From: huyufei Date: Sun, 31 Mar 2024 18:36:47 +0800 Subject: [PATCH] =?UTF-8?q?udpate:=20=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=B7=BB=E5=8A=A0=20=E5=8E=BB=E5=B9=BF=E5=91=8A=20?= =?UTF-8?q?=E5=92=8C=20banner=20=E8=83=8C=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/Config/GuruSDKInitConfig.cs | 12 ++++++++++++ Runtime/Code/SDK/GuruSDK.Ads.cs | 13 +++++++++++-- Runtime/Code/SDK/GuruSDK.cs | 5 ++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Runtime/Code/Config/GuruSDKInitConfig.cs b/Runtime/Code/Config/GuruSDKInitConfig.cs index f23b92e..b708364 100644 --- a/Runtime/Code/Config/GuruSDKInitConfig.cs +++ b/Runtime/Code/Config/GuruSDKInitConfig.cs @@ -28,6 +28,14 @@ namespace Guru /// public string CustomServiceKey = ""; /// + /// Banner 背景颜色 Hex 值 + /// + public string BannerBackgroundColor = "#00000000"; + /// + /// 已购买去广告道具 + /// + public bool IsBuyNoAds = false; + /// /// Debug模式(默认关闭) /// public bool DebugMode = false; @@ -54,6 +62,8 @@ namespace Guru bool autoLoadAds = true, bool iapEnabled = true, bool autoRecordFinishedLevels = true, + bool isBuyNoAds = false, + string bannerBackgroundColor = "#00000000", bool debugMode = false, Dictionary defaultRemoteData = null, byte[] googleKeys = null, @@ -66,6 +76,8 @@ namespace Guru AutoLoadWhenAdsReady = autoLoadAds, IAPEnabled = iapEnabled, AutoRecordFinishedLevels = autoRecordFinishedLevels, + IsBuyNoAds = isBuyNoAds, + BannerBackgroundColor = bannerBackgroundColor, DebugMode = debugMode, GoogleKeys = googleKeys, AppleRootCerts = appleRootCerts, diff --git a/Runtime/Code/SDK/GuruSDK.Ads.cs b/Runtime/Code/SDK/GuruSDK.Ads.cs index 5120540..51bd74c 100644 --- a/Runtime/Code/SDK/GuruSDK.Ads.cs +++ b/Runtime/Code/SDK/GuruSDK.Ads.cs @@ -239,6 +239,10 @@ namespace Guru /// internal static void StartAdService(AdsInitSpec spec = null) { + + //---------- Using InitConfig ---------- + if (InitConfig is { IsBuyNoAds: true }) SetBuyNoAds(true); + LogI($"StartAdService"); if (spec == null) { @@ -248,14 +252,19 @@ namespace Guru spec = AdsInitSpec.BuildWithNoAds(InitConfig.AutoLoadWhenAdsReady, IsDebugMode); } } - ADService.Instance.StartService(OnAdsInitComplete, spec); - //--------- Callbacks ----------- + if(InitConfig != null && !string.IsNullOrEmpty(InitConfig.BannerBackgroundColor)) + spec.bannerColorHex = InitConfig.BannerBackgroundColor; + + //--------- Add Callbacks ----------- ADService.OnBannerLoaded = OnBannerLoaded; ADService.OnInterstitialLoaded = OnInterstitialLoaded; ADService.OnInterstitialFailed = OnInterstitialFailed; ADService.OnRewardLoaded = OnRewardLoaded; ADService.OnRewardFailed = OnRewardFailed; + + // ---------- Start Services ---------- + ADService.Instance.StartService(OnAdsInitComplete, spec); } private static void OnBannerLoaded() diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 3867baa..3f89e57 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -92,12 +92,15 @@ namespace Guru bool iapEnabled = true, bool autoRecordFinishedLevels = true, bool debugMode = false, + bool isBuyNoAds = false, + string bannerColor = "#00000000", Dictionary defaultRemoteData = null, byte[] googleKeys = null, byte[] appleRootCerts = null) { var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled, - autoRecordFinishedLevels, debugMode, defaultRemoteData, googleKeys, appleRootCerts); + autoRecordFinishedLevels, isBuyNoAds, bannerColor, + debugMode, defaultRemoteData, googleKeys, appleRootCerts); return config; }