udpate: 初始化参数添加 去广告 和 banner 背景色

deeplink
胡宇飞 2024-03-31 18:36:47 +08:00
parent fec486e8a6
commit 311b53ea5f
3 changed files with 27 additions and 3 deletions

View File

@ -28,6 +28,14 @@ namespace Guru
/// </summary>
public string CustomServiceKey = "";
/// <summary>
/// Banner 背景颜色 Hex 值
/// </summary>
public string BannerBackgroundColor = "#00000000";
/// <summary>
/// 已购买去广告道具
/// </summary>
public bool IsBuyNoAds = false;
/// <summary>
/// Debug模式默认关闭
/// </summary>
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<string, object> 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,

View File

@ -239,6 +239,10 @@ namespace Guru
/// </summary>
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()

View File

@ -92,12 +92,15 @@ namespace Guru
bool iapEnabled = true,
bool autoRecordFinishedLevels = true,
bool debugMode = false,
bool isBuyNoAds = false,
string bannerColor = "#00000000",
Dictionary<string, object> 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;
}