diff --git a/Runtime/GuruAds/Amazon/Runtime/AdChanelAmazon.cs b/Runtime/GuruAds/Amazon/Runtime/AdChanelAmazon.cs index 0521ea7..903710c 100644 --- a/Runtime/GuruAds/Amazon/Runtime/AdChanelAmazon.cs +++ b/Runtime/GuruAds/Amazon/Runtime/AdChanelAmazon.cs @@ -79,7 +79,7 @@ namespace Guru /// /// 初始化平台 /// - public void Initialize() + public void Initialize(bool isDebug = false) { #if UNITY_EDITOR Debug.Log($"=== Amazon will not init on Editor ==="); @@ -93,11 +93,8 @@ namespace Guru // 初始化Amazon Amazon.Initialize (AmazonAppID); Amazon.SetAdNetworkInfo(new AdNetworkInfo(DTBAdNetwork.MAX)); -#if UNITY_EDITOR || DEBUG - Amazon.EnableTesting (true); // Make sure to take this off when going live. -#else - Amazon.EnableLogging (false); -#endif + Amazon.EnableTesting (isDebug); // Make sure to take this off when going live. + Amazon.EnableLogging (isDebug); #if UNITY_IOS Amazon.SetAPSPublisherExtendedIdFeatureEnabled(true); diff --git a/Runtime/GuruAds/Pubmatic/Runtime/AdChannelPubMatic.cs b/Runtime/GuruAds/Pubmatic/Runtime/AdChannelPubMatic.cs index 2cce42d..2ada5b5 100644 --- a/Runtime/GuruAds/Pubmatic/Runtime/AdChannelPubMatic.cs +++ b/Runtime/GuruAds/Pubmatic/Runtime/AdChannelPubMatic.cs @@ -50,7 +50,7 @@ namespace Guru * before it can request an ad using OpenWrap SDK. * The storeURL is the URL where users can download your app from the App Store/Google Play Store. */ - public void Initialize() + public void Initialize(bool isDebug = false) { #if UNITY_EDITOR Debug.Log($"=== PubMatic will not init on Editor ==="); diff --git a/Runtime/GuruCore/Runtime/Ads/ADService.cs b/Runtime/GuruCore/Runtime/Ads/ADService.cs index 7a6e085..6c24ddc 100644 --- a/Runtime/GuruCore/Runtime/Ads/ADService.cs +++ b/Runtime/GuruCore/Runtime/Ads/ADService.cs @@ -23,7 +23,7 @@ namespace Guru protected override void InitService() { base.InitService(); - InitChannels(); // 启动各广告渠道代理 + InitChannels(_isDebug); // 启动各广告渠道代理 } #endregion @@ -37,14 +37,14 @@ namespace Guru /// /// 各渠道初始化 /// - private void InitChannels() + private void InitChannels(bool isDebug) { _adChannels = new HashSet(); IAdChannel channel = null; _asyncLoader = null; _chanelMax = new AdChanelMax(); // 默认持有MAXChannel - _chanelMax.Initialize(); + _chanelMax.Initialize(isDebug); if(_initSpec != null) _chanelMax.SetBannerBackColor(_initSpec.bannerColorHex); //------------ 以下为扩展的广告渠道 ------------------ @@ -52,7 +52,7 @@ namespace Guru // 开启渠道需要添加对应的宏 channel = new AdChanelAmazon(); - channel.Initialize(); + channel.Initialize(isDebug); _adChannels.Add(channel); // Amazon _asyncLoader = channel as IAsyncRequestChannel; if (_asyncLoader != null) diff --git a/Runtime/GuruCore/Runtime/Ads/ADServiceBase.cs b/Runtime/GuruCore/Runtime/Ads/ADServiceBase.cs index cabf385..82e5402 100644 --- a/Runtime/GuruCore/Runtime/Ads/ADServiceBase.cs +++ b/Runtime/GuruCore/Runtime/Ads/ADServiceBase.cs @@ -49,6 +49,7 @@ namespace Guru } } + internal bool _isDebug = false; /// /// 启动广告服务 @@ -61,20 +62,22 @@ namespace Guru if (IsInitialized) return; // 已经初始化后, 无需再次初始化 _initSpec = initSpec; + if (_initSpec == null) _initSpec = AdsInitSpec.BuildDefault(); + + _isDebug = _initSpec.isDebug; _isServiceStarted = true; _onSdkInitReady = callback; if(_model == null) _model = AdsModel.Create(); this.Log("AD SDK Start Init"); - InitMaxAds(); // 初始化 MAX 广告 - + InitMaxCallbacks(); // 初始化 MAX 广告 InitService(); // 内部继承接口 } /// /// 初始化 MAX 广告组件 /// - private void InitMaxAds() + private void InitMaxCallbacks() { //-------------- 初始化回调 ------------------ MaxSdkCallbacks.OnSdkInitializedEvent += OnMaxSdkInitializedCallBack; @@ -103,8 +106,6 @@ namespace Guru MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent; //-------------- SDK 初始化 ------------------- - if (_initSpec == null) _initSpec = AdsInitSpec.BuildDefault(); - MaxSdk.SetVerboseLogging(_initSpec.isDebug); MaxSdk.SetExtraParameter("enable_black_screen_fixes", "true"); // 修复黑屏 } diff --git a/Runtime/GuruCore/Runtime/Ads/Channels/Max/AdChanelMax.cs b/Runtime/GuruCore/Runtime/Ads/Channels/Max/AdChanelMax.cs index 79a4cd2..e675a24 100644 --- a/Runtime/GuruCore/Runtime/Ads/Channels/Max/AdChanelMax.cs +++ b/Runtime/GuruCore/Runtime/Ads/Channels/Max/AdChanelMax.cs @@ -32,10 +32,11 @@ namespace Guru /// /// MAX 渠道初始化, 启动服务 /// - public void Initialize() + public void Initialize(bool isDebug = false) { MaxSdk.SetSdkKey(GuruSettings.Instance.ADSetting.SDK_KEY); MaxSdk.SetUserId(IPMConfig.IPM_UID); // 上报用户ID + MaxSdk.SetVerboseLogging(isDebug); // 设置调试数据 MaxSdk.InitializeSdk(); } diff --git a/Runtime/GuruCore/Runtime/Ads/IAdChannel.cs b/Runtime/GuruCore/Runtime/Ads/IAdChannel.cs index fd6ec3b..2704bf7 100644 --- a/Runtime/GuruCore/Runtime/Ads/IAdChannel.cs +++ b/Runtime/GuruCore/Runtime/Ads/IAdChannel.cs @@ -8,7 +8,7 @@ namespace Guru { // Action OnRequestOver { get; set; } - void Initialize(); + void Initialize(bool isDebug = false); string Name { get;}