diff --git a/Assets/Script/Common/FileParse/FileParse.cs b/Assets/Script/Common/FileParse/FileParse.cs index 9c77877..6d82b91 100644 --- a/Assets/Script/Common/FileParse/FileParse.cs +++ b/Assets/Script/Common/FileParse/FileParse.cs @@ -5,10 +5,9 @@ using System.IO; using System.Security.Cryptography; using System.Text; using Google.MiniJSON; -using Script.Utils; using UnityEngine; -namespace Script.Common.FileParse +namespace WZ { public static class FileParse diff --git a/Assets/Script/Common/IAdService.cs b/Assets/Script/Common/IAdService.cs index 0a269e5..f533085 100644 --- a/Assets/Script/Common/IAdService.cs +++ b/Assets/Script/Common/IAdService.cs @@ -1,7 +1,6 @@ using System; -using Script.SDKManager.AdsSDKManager.Constant; -namespace Script.Common +namespace WZ { /// /// 提供广告SDK功能的统一接口 diff --git a/Assets/Script/Common/IvRulesData.cs b/Assets/Script/Common/IvRulesData.cs index 51d21d4..00926e9 100644 --- a/Assets/Script/Common/IvRulesData.cs +++ b/Assets/Script/Common/IvRulesData.cs @@ -1,6 +1,6 @@ using System; -namespace Script.Common +namespace WZ { [System.Serializable] public class IvRulesData diff --git a/Assets/Script/Common/RevenueData.cs b/Assets/Script/Common/RevenueData.cs index 9e3026b..b1b3eb8 100644 --- a/Assets/Script/Common/RevenueData.cs +++ b/Assets/Script/Common/RevenueData.cs @@ -1,4 +1,4 @@ -namespace Script.Common +namespace WZ { [System.Serializable] public class RevenueData diff --git a/Assets/Script/Common/StaticValue.cs b/Assets/Script/Common/StaticValue.cs index f4c857c..3bf5397 100644 --- a/Assets/Script/Common/StaticValue.cs +++ b/Assets/Script/Common/StaticValue.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.Common +namespace WZ { public static class StaticValue diff --git a/Assets/Script/SDKManager/AdjustManager/AdjustManager.cs b/Assets/Script/SDKManager/AdjustManager/AdjustManager.cs index f47a7d3..682192f 100644 --- a/Assets/Script/SDKManager/AdjustManager/AdjustManager.cs +++ b/Assets/Script/SDKManager/AdjustManager/AdjustManager.cs @@ -1,9 +1,9 @@ using System.Collections; using System.Collections.Generic; using AdjustSdk; -using Script.Utils; using Unity.VisualScripting; using UnityEngine; +using WZ; public class AdjustManager : NormalSingleton { diff --git a/Assets/Script/SDKManager/AdjustManager/AdjustNetwork.cs b/Assets/Script/SDKManager/AdjustManager/AdjustNetwork.cs index cc88c3c..b997f84 100644 --- a/Assets/Script/SDKManager/AdjustManager/AdjustNetwork.cs +++ b/Assets/Script/SDKManager/AdjustManager/AdjustNetwork.cs @@ -1,6 +1,7 @@ using System.Collections; -using Script.Utils; + using UnityEngine; +using WZ; public class AdjustNetwork : NormalSingleton { diff --git a/Assets/Script/SDKManager/AdjustManager/AdjustTrackEvent.cs b/Assets/Script/SDKManager/AdjustManager/AdjustTrackEvent.cs index db74554..5bd99f1 100644 --- a/Assets/Script/SDKManager/AdjustManager/AdjustTrackEvent.cs +++ b/Assets/Script/SDKManager/AdjustManager/AdjustTrackEvent.cs @@ -1,9 +1,8 @@ using AdjustSdk; using Firebase.RemoteConfig; using Newtonsoft.Json; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.Utils; +using WZ; + public class AdjustTrackEvent : NormalSingleton { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobAdsManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobAdsManager.cs index 234480b..881cfc9 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobAdsManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobAdsManager.cs @@ -2,15 +2,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; using GoogleMobileAds.Api; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager +namespace WZ { public class AdmobAdsManager : NormalSingleton, IAdService @@ -52,8 +47,6 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager if (_bannerAdUnits.Count > 0) LoadBanner(); if (_interstitialAdUnits.Count > 0) LoadInterstitial(); if (_rewardedAdUnits.Count > 0) LoadRewarded(); - if (_splashAdUnits.Count > 0) LoadSplash(); - _initialized = true; LoggerUtils.Debug("[Admob] init success"); }); @@ -268,14 +261,16 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager } - private void OnSplashAdDismissed(string adSource,string adUnitId,double revenue) + private void OnSplashAdDismissed(string adSource, string adUnitId, double revenue) { AdsActionEvents.TrackAdClosed(Platfrom, adSource, adUnitId, AdsType.Splash, "", revenue); + AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke(); } private void OnSplashAdError(string adUnitId, int errorCode, string errorMsg) { - AdsActionEvents.TrackAdFailToShow(Platfrom,AdsType.Splash,errorMsg,""); + AdsActionEvents.TrackAdFailToShow(Platfrom, AdsType.Splash, errorMsg, ""); + AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke(); } private void OnSplashAdClicked(string adSource,string adUnitId,double revenue) @@ -294,7 +289,6 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager #region 原生广告功能 public void LoadNative() { - throw new System.NotImplementedException(); } public double GetNativeRevenue() { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobBannerAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobBannerAdManager.cs index e1e0997..faccde0 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobBannerAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobBannerAdManager.cs @@ -1,12 +1,8 @@ using System.Collections.Generic; using GoogleMobileAds.Api; using System; -using Script.Utils; -using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager +namespace WZ { public class AdmobBannerAdManager { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobInterstitialAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobInterstitialAdManager.cs index 8e887b6..545c94a 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobInterstitialAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobInterstitialAdManager.cs @@ -1,12 +1,8 @@ using System; using System.Collections.Generic; using GoogleMobileAds.Api; -using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.Utils; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager +namespace WZ { public class AdmobInterstitialAdManager { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobNativeAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobNativeAdManager.cs index 6023968..db631f6 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobNativeAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobNativeAdManager.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager +namespace WZ { public class AdmobNativeAdManager : MonoBehaviour { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobRewardedAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobRewardedAdManager.cs index 51191e0..5d6817a 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobRewardedAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobRewardedAdManager.cs @@ -1,13 +1,9 @@ using System; using System.Collections.Generic; using GoogleMobileAds.Api; -using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.Utils; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager +namespace WZ { public class AdmobRewardedAdManager { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobSplashAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobSplashAdManager.cs index fad406b..b595332 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobSplashAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/AdmobSplashAdManager.cs @@ -2,13 +2,9 @@ using System; using System.Collections; using System.Collections.Generic; using GoogleMobileAds.Api; -using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager +namespace WZ { public class AdmobSplashAdManager { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/Utils/AdmobTools.cs b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/Utils/AdmobTools.cs index dde317b..6cde5cc 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/Utils/AdmobTools.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdmobAdsManager/Utils/AdmobTools.cs @@ -2,11 +2,10 @@ using System; using System.Linq; using System.Reflection; using GoogleMobileAds.Api; -using Script.Utils; using UnityEngine; using Newtonsoft.Json.Linq; -namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils +namespace WZ { public class AdmobUtils { diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs index 86fd967..34e8d8f 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs @@ -3,378 +3,394 @@ using System.Collections.Generic; using System.Linq; using Firebase.RemoteConfig; using Newtonsoft.Json; -using Script.Common; -using Script.SDKManager.AdsSDKManager.AdmobAdsManager; -using Script.SDKManager.AdsSDKManager.BigoAdsManager; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.SDKManager.AdsSDKManager.MaxAdsManager; -using Script.SDKManager.AdsSDKManager.TpnAdsManager; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; using UnityEngine; -public class AdsSDKManager : NormalSingleton +namespace WZ { - private List _adNetworks = new List(); - /// - /// 看完广告的回调 - /// - private Action AdRewardCallback; - - /// - /// 广告竞价开关:激励、插屏、全屏Native广告竞价 - /// - public bool IsMoreAdsBidding = false; - - public void InitSDK() + public class AdsSDKManager : NormalSingleton { - // 初始化广告平台状态 - BidPlatformManager.Instance.InitializePlatformStates(AdConfigParser.GetAdExpireInSec()); - InitializeAdNetworks(); - } + private List _adNetworks = new List(); + // 是否有激励视频或者插屏广告在展示 + public bool otherAdsOnShow = false; + /// + /// 看完广告的回调 + /// + private Action AdRewardCallback; - private void InitializeAdNetworks() - { - _adNetworks.Add(AdmobAdsManager.Instance); - _adNetworks.Add(BigoAdsManager.Instance); - _adNetworks.Add(TpnAdsManager.Instance); - _adNetworks.Add(MaxAdsManager.Instance); + /// + /// 广告竞价开关:激励、插屏、全屏Native广告竞价 + /// + public bool IsMoreAdsBidding = false; - foreach (var network in _adNetworks) + public Action OnSplashAdCloseCallback; + + public void InitSDK(Action action) { - network.Initialize(); - } - } - - public bool IsRewardAdReady() - { - return _adNetworks.Any(network => network.IsRewardedAvailable()); - } - - /// - /// 展示激励广告 - /// - /// - public void ShowRewardAd(string _adPos, Action _rewardCallback = null, Action _showFailedCallback = null) - { - AdsActionEvents.TrackAdPosition(AdsType.Rewarded, _adPos); - if (!IsRewardAdReady()) - { - _showFailedCallback?.Invoke(); - return; + OnSplashAdCloseCallback = action; + // 初始化广告平台状态 + BidPlatformManager.Instance.InitializePlatformStates(AdConfigParser.GetAdExpireInSec()); + InitializeAdNetworks(); } - PlatformType result = GetBestPlatformType(false); - BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Rewarded); - if (result == PlatformType.AppLovin) - { - MaxAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); - } - else if (result == PlatformType.Admob) - { - AdmobAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); - } - else if (result == PlatformType.Bigo) - { - BigoAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); - } - else if (result == PlatformType.Topon) - { - TpnAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); - } - else if (result == PlatformType.Kwai) + private void InitializeAdNetworks() { + _adNetworks.Add(AdmobAdsManager.Instance); + _adNetworks.Add(BigoAdsManager.Instance); + _adNetworks.Add(TpnAdsManager.Instance); + _adNetworks.Add(MaxAdsManager.Instance); - } - else - { - _showFailedCallback?.Invoke(); - } - AdPlayCountManager.IncrementAdPlayCount(AdsType.Rewarded); - CheckAndRefreshExpiredBids(AdsType.Rewarded); - } - - public bool IsInterstitialReady() - { - return _adNetworks.Any(network => network.IsInterstitialAvailable()); - } - - /// - /// 展示激励广告 - /// - /// - public void ShowInterstitialAd(string _adPos, IvType _IvType = IvType.IV1, Action _closeCallback = null) - { - AdsActionEvents.TrackAdPosition(AdsType.Interstitial, _adPos); - if (!IsRewardAdReady()) - { - _closeCallback?.Invoke(); - _closeCallback = null; - return; - } - - PlatformType result = GetBestPlatformType(true); - BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Interstitial); - if (result == PlatformType.AppLovin) - { - MaxAdsManager.Instance.DisplayInterstitial(_adPos, _IvType,_closeCallback); - } - else if (result == PlatformType.Admob) - { - AdmobAdsManager.Instance.DisplayInterstitial(_adPos, _IvType,_closeCallback); - } - else if (result == PlatformType.Bigo) - { - BigoAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback); - } - else if (result == PlatformType.Topon) - { - TpnAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback); - } - else if (result == PlatformType.Kwai) - { - - } - else - { - _closeCallback?.Invoke(); - } - - AdPlayCountManager.IncrementAdPlayCount(AdsType.Interstitial); - // 刷新其他类型广告 - CheckAndRefreshExpiredBids(AdsType.Interstitial); - } - - private PlatformType GetBestPlatformType(bool isInterstitial) - { - if (isInterstitial) - { - AdPriceInfo priceInfo = new AdPriceInfo( - maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(), - admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(), - bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(), - // todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置 - kwaiPrice: 0, - toponAdUnitId: TpnAdsManager.Instance.topon_interstitial_units - ); - return AdsBidResult.GetPlatformType(priceInfo); - } - else - { - AdPriceInfo priceInfo = new AdPriceInfo( - maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(), - admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(), - bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(), - // todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置 - kwaiPrice: 0, - toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units - ); - return AdsBidResult.GetPlatformType(priceInfo); - } - } - - // 检查并刷新过期竞价 - private void CheckAndRefreshExpiredBids(AdsType _adsType) - { - Dictionary> expiredBids = BidPlatformManager.Instance.GetExpiredBids(); - - foreach (var kvp in expiredBids) - { - PlatformType platformName = kvp.Key; - foreach (AdsType adType in kvp.Value) + foreach (var network in _adNetworks) { - if (_adsType == adType) - { - LoggerUtils.Debug($"{platformName} 平台 {adType} 广告竞价已过期,重新加载广告"); - RefreshPlatformAds(platformName, adType); - } + network.Initialize(); + } + AdsSplashManager.Instance.InitSplash(); + } + + public bool IsRewardAdReady() + { + return _adNetworks.Any(network => network.IsRewardedAvailable()); + } + + /// + /// 展示激励广告 + /// + /// + public void ShowRewardAd(string _adPos, Action _rewardCallback = null, Action _showFailedCallback = null) + { + AdsActionEvents.TrackAdPosition(AdsType.Rewarded, _adPos); + if (!IsRewardAdReady()) + { + _showFailedCallback?.Invoke(); + return; + } + PlatformType result = GetBestPlatformType(false); + BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Rewarded); + if (result == PlatformType.AppLovin) + { + MaxAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); + } + else if (result == PlatformType.Admob) + { + AdmobAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); + } + else if (result == PlatformType.Bigo) + { + BigoAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); + } + else if (result == PlatformType.Topon) + { + TpnAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback); + } + else if (result == PlatformType.Kwai) + { + + } + else + { + _showFailedCallback?.Invoke(); + } + AdPlayCountManager.IncrementAdPlayCount(AdsType.Rewarded); + CheckAndRefreshExpiredBids(AdsType.Rewarded); + } + + public bool IsInterstitialReady() + { + return _adNetworks.Any(network => network.IsInterstitialAvailable()); + } + + /// + /// 展示激励广告 + /// + /// + public void ShowInterstitialAd(string _adPos, IvType _IvType = IvType.IV1, Action _closeCallback = null) + { + AdsActionEvents.TrackAdPosition(AdsType.Interstitial, _adPos); + if (!IsRewardAdReady()) + { + _closeCallback?.Invoke(); + _closeCallback = null; + return; + } + otherAdsOnShow = true; + PlatformType result = GetBestPlatformType(true); + BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Interstitial); + if (result == PlatformType.AppLovin) + { + MaxAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback); + } + else if (result == PlatformType.Admob) + { + AdmobAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback); + } + else if (result == PlatformType.Bigo) + { + BigoAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback); + } + else if (result == PlatformType.Topon) + { + TpnAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback); + } + else if (result == PlatformType.Kwai) + { + + } + else + { + _closeCallback?.Invoke(); + } + + AdPlayCountManager.IncrementAdPlayCount(AdsType.Interstitial); + // 刷新其他类型广告 + CheckAndRefreshExpiredBids(AdsType.Interstitial); + } + + #region 开屏广告 + public bool IsSplashAvailable() + { + return _adNetworks.Any(network => network.IsSplashAvailable()); + } + + public void ShowSplashAd() + { + AdmobAdsManager.Instance.DisplaySplash(); + } + + public void LoadSplashAd() + { + AdmobAdsManager.Instance.LoadSplash(); + } + #endregion + + private PlatformType GetBestPlatformType(bool isInterstitial) + { + if (isInterstitial) + { + AdPriceInfo priceInfo = new AdPriceInfo( + maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(), + admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(), + bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(), + // todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置 + kwaiPrice: 0, + toponAdUnitId: TpnAdsManager.Instance.topon_interstitial_units + ); + return AdsBidResult.GetPlatformType(priceInfo); + } + else + { + AdPriceInfo priceInfo = new AdPriceInfo( + maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(), + admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(), + bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(), + // todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置 + kwaiPrice: 0, + toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units + ); + return AdsBidResult.GetPlatformType(priceInfo); } } - } - private void RefreshPlatformAds(PlatformType platformName, AdsType adType) - { - switch (platformName) - { - case PlatformType.Admob: - RefreshAdmobAds(adType); - break; - case PlatformType.Topon: - RefreshTopOnAds(adType); - break; - case PlatformType.AppLovin: - RefreshMaxAds(adType); - break; - case PlatformType.Bigo: - RefreshBigoAds(adType); - break; - case PlatformType.Kwai: - RefreshKwaiAds(adType); - break; - default: - break; - } - } - private void RefreshAdmobAds(AdsType adType) - { - switch (adType) + // 检查并刷新过期竞价 + private void CheckAndRefreshExpiredBids(AdsType _adsType) { - case AdsType.Rewarded: - AdmobAdsManager.Instance.LoadRewarded(); - break; - case AdsType.Interstitial: - AdmobAdsManager.Instance.LoadInterstitial(); - break; - case AdsType.Banner: - AdmobAdsManager.Instance.LoadBanner(); - break; - case AdsType.Native: - AdmobAdsManager.Instance.LoadNative(); - break; - case AdsType.Splash: - AdmobAdsManager.Instance.LoadSplash(); - break; - default: - break; - } - } - - // 刷新TopOn广告 - private void RefreshTopOnAds(AdsType adType) - { - switch (adType) - { - case AdsType.Rewarded: - TpnAdsManager.Instance.LoadRewarded(); - break; - case AdsType.Interstitial: - TpnAdsManager.Instance.LoadInterstitial(); - break; - default: - break; - } - } - - // 刷新Max广告 - private void RefreshMaxAds(AdsType adType) - { - switch (adType) - { - case AdsType.Rewarded: - MaxAdsManager.Instance.LoadRewarded(); - break; - case AdsType.Interstitial: - MaxAdsManager.Instance.LoadInterstitial(); - break; - default: - break; - } - } - - // 刷新Bigo广告 - private void RefreshBigoAds(AdsType adType) - { - switch (adType) - { - case AdsType.Rewarded: - BigoAdsManager.Instance.LoadRewarded(); - break; - case AdsType.Interstitial: - BigoAdsManager.Instance.LoadInterstitial(); - break; - default: - break; - } - } + Dictionary> expiredBids = BidPlatformManager.Instance.GetExpiredBids(); - private void RefreshKwaiAds (AdsType adType) - { - switch (adType) - { - case AdsType.Rewarded: - // todo: 刷新激励广告 - KwaiAdsManager.Instance.LoadRewardAd(); - break; - case AdsType.Interstitial: - // todo: 刷新插屏广告 - KwaiAdsManager.Instance.LoadInterstitialAd(); - break; - default: - break; - } - } - - /// - /// 广告看完回调 - /// - public void OnRewardAdCallback(double price) - { - AdRewardCallback?.Invoke(price); - AdRewardCallback = null; - } - - /// - /// 根据IvRules判断是否可以展示插屏 - /// - /// - public bool IvRulesShow(IvType ivadType) - { - //1.获取远程配置 - string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES"); - if (string.IsNullOrEmpty(json)) - { - return true; - } - //2.解析配置 - var dates = JsonConvert.DeserializeObject(json); - if (dates == null && dates.Length == 0) - { - return true; - } - //3.获取IVADType对应的配置 - IvRulesData ivRulesData = null; - foreach (var data in dates) - { - if (data.type == (int)ivadType) + foreach (var kvp in expiredBids) { - ivRulesData = data; + PlatformType platformName = kvp.Key; + foreach (AdsType adType in kvp.Value) + { + if (_adsType == adType) + { + LoggerUtils.Debug($"{platformName} 平台 {adType} 广告竞价已过期,重新加载广告"); + RefreshPlatformAds(platformName, adType); + } + } } } - if (ivRulesData == null) + private void RefreshPlatformAds(PlatformType platformName, AdsType adType) { + switch (platformName) + { + case PlatformType.Admob: + RefreshAdmobAds(adType); + break; + case PlatformType.Topon: + RefreshTopOnAds(adType); + break; + case PlatformType.AppLovin: + RefreshMaxAds(adType); + break; + case PlatformType.Bigo: + RefreshBigoAds(adType); + break; + case PlatformType.Kwai: + RefreshKwaiAds(adType); + break; + default: + break; + } + } + + private void RefreshAdmobAds(AdsType adType) + { + switch (adType) + { + case AdsType.Rewarded: + AdmobAdsManager.Instance.LoadRewarded(); + break; + case AdsType.Interstitial: + AdmobAdsManager.Instance.LoadInterstitial(); + break; + case AdsType.Banner: + AdmobAdsManager.Instance.LoadBanner(); + break; + case AdsType.Native: + AdmobAdsManager.Instance.LoadNative(); + break; + case AdsType.Splash: + AdmobAdsManager.Instance.LoadSplash(); + break; + default: + break; + } + } + + // 刷新TopOn广告 + private void RefreshTopOnAds(AdsType adType) + { + switch (adType) + { + case AdsType.Rewarded: + TpnAdsManager.Instance.LoadRewarded(); + break; + case AdsType.Interstitial: + TpnAdsManager.Instance.LoadInterstitial(); + break; + default: + break; + } + } + + // 刷新Max广告 + private void RefreshMaxAds(AdsType adType) + { + switch (adType) + { + case AdsType.Rewarded: + MaxAdsManager.Instance.LoadRewarded(); + break; + case AdsType.Interstitial: + MaxAdsManager.Instance.LoadInterstitial(); + break; + default: + break; + } + } + + // 刷新Bigo广告 + private void RefreshBigoAds(AdsType adType) + { + switch (adType) + { + case AdsType.Rewarded: + BigoAdsManager.Instance.LoadRewarded(); + break; + case AdsType.Interstitial: + BigoAdsManager.Instance.LoadInterstitial(); + break; + default: + break; + } + } + + private void RefreshKwaiAds(AdsType adType) + { + switch (adType) + { + case AdsType.Rewarded: + // todo: 刷新激励广告 + KwaiAdsManager.Instance.LoadRewardAd(); + break; + case AdsType.Interstitial: + // todo: 刷新插屏广告 + KwaiAdsManager.Instance.LoadInterstitialAd(); + break; + default: + break; + } + } + + /// + /// 广告看完回调 + /// + public void OnRewardAdCallback(double price) + { + AdRewardCallback?.Invoke(price); + AdRewardCallback = null; + } + + /// + /// 根据IvRules判断是否可以展示插屏 + /// + /// + public bool IvRulesShow(IvType ivadType) + { + //1.获取远程配置 + string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES"); + if (string.IsNullOrEmpty(json)) + { + return true; + } + //2.解析配置 + var dates = JsonConvert.DeserializeObject(json); + if (dates == null && dates.Length == 0) + { + return true; + } + //3.获取IVADType对应的配置 + IvRulesData ivRulesData = null; + foreach (var data in dates) + { + if (data.type == (int)ivadType) + { + ivRulesData = data; + } + } + if (ivRulesData == null) + { + return true; + } + //4.判断skip(次安装跳过几次触发不展示广告) + int skipLevel = ivRulesData.skipLevel; + int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0); + if (currentSkipLevel < skipLevel) + { + LoggerUtils.Debug($"[SDK] skipLevel limit"); + PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1); + return false; + } + //5.判断overLevel(没跳过几次触发) + int overLevel = ivRulesData.overLevel; + int currentOverLevel = IvRulesConst.CurrentOverLevel; + if (currentOverLevel < overLevel) + { + LoggerUtils.Debug($"[SDK] overLevel limit"); + IvRulesConst.CurrentOverLevel++; + return false; + } + + //6.判断interval(广告时间间隔) + int interval = ivRulesData.interval; + long currentInterval = IvRulesConst.CurrentInterval; + long localTimestamp = TimeUtils.GetLocalTimestamp(); + + if (localTimestamp < currentInterval + (interval * 1000L)) + { + LoggerUtils.Debug($"[SDK] interval limit"); + return false; + } + return true; } - //4.判断skip(次安装跳过几次触发不展示广告) - int skipLevel = ivRulesData.skipLevel; - int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0); - if (currentSkipLevel < skipLevel) - { - LoggerUtils.Debug($"[SDK] skipLevel limit"); - PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1); - return false; - } - //5.判断overLevel(没跳过几次触发) - int overLevel = ivRulesData.overLevel; - int currentOverLevel = IvRulesConst.CurrentOverLevel; - if (currentOverLevel < overLevel) - { - LoggerUtils.Debug($"[SDK] overLevel limit"); - IvRulesConst.CurrentOverLevel++; - return false; - } - - //6.判断interval(广告时间间隔) - int interval = ivRulesData.interval; - long currentInterval = IvRulesConst.CurrentInterval; - long localTimestamp = TimeUtils.GetLocalTimestamp(); - - if (localTimestamp < currentInterval + (interval * 1000L)) - { - LoggerUtils.Debug($"[SDK] interval limit"); - return false; - } - - return true; } -} +} \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdsSplashManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdsSplashManager.cs new file mode 100644 index 0000000..eab8ab5 --- /dev/null +++ b/Assets/Script/SDKManager/AdsSDKManager/AdsSplashManager.cs @@ -0,0 +1,203 @@ +using System.Collections; +using System.Collections.Generic; +using Firebase.RemoteConfig; +using GoogleMobileAds.Api; +using GoogleMobileAds.Common; +using UnityEngine; + +namespace WZ +{ + + + public class AdsSplashManager : MonoBehaviour + { + public static AdsSplashManager Instance { get; private set; } + public float backgroundTime = 0; + private int timeoutDuration = 5; + private bool _coldLaunch = true; + + + private void Awake() + { + if (Instance != null && Instance != this) + { + Destroy(gameObject); + return; + } + Instance = this; + DontDestroyOnLoad(gameObject); + } + + public void InitSplash() + { + timeoutDuration = GetSplashConfigItem().loadtime; + StartCoroutine(LoadSplashAdAdWithTimeout()); + } + + private void OnAppStateChanged(AppState state) + { + if (_coldLaunch) + { + _coldLaunch = false; + return; + } + if (state == AppState.Foreground) + { + LoggerUtils.Debug("[AppOpen] 进入前台"); + CheckSplashAdlash(false); + } + else if (state == AppState.Background) + { + backgroundTime = Time.realtimeSinceStartup; + LoggerUtils.Debug("[AppOpen] 进入后台 :" + backgroundTime); + } + } + + + private IEnumerator LoadSplashAdAdWithTimeout() + { + // 开始加载广告 + AdsSDKManager.Instance.LoadSplashAd(); + // 等待5秒或直到广告加载完成 + float elapsedTime = 0f; + while (elapsedTime < timeoutDuration && !AdsSDKManager.Instance.IsSplashAvailable()) + { + elapsedTime += Time.deltaTime; + yield return null; + } + + CheckSplashAdlash(true); + } + + IEnumerator DelayedAction() + { + yield return new WaitForSeconds(1f); + CheckSplashAdlash(false); + } + + private void CheckSplashAdlash(bool isCold) + { + if (!isCold) + { + // 热启动 + // 当前有其他类型广告在展示 + LoggerUtils.Debug(" [AppOpen] 热启动 是否有广告在展示:" + AdsSDKManager.Instance.otherAdsOnShow); + if (AdsSDKManager.Instance.otherAdsOnShow) return; + + // 热启动开关 + var hotSplashSwitch = GetSplashConfigItem().hot_splash_switch == 1; + LoggerUtils.Debug(" [AppOpen] 热启动 开关:" + hotSplashSwitch); + if (!hotSplashSwitch) + { + return; + } + + // 后台运行时间 + float resultTime = Time.realtimeSinceStartup - backgroundTime; + float onlineTime = GetSplashConfigItem().hot_timegap; + LoggerUtils.Debug(" [AppOpen] 后台运行时间差值:" + resultTime + " 在线参数值:" + onlineTime); + if (resultTime < onlineTime) + { + return; + } + + if (!AdsSDKManager.Instance.IsSplashAvailable()) + { + LoggerUtils.Debug(" [AppOpen] 热启动 广告是否准备好:"); + AdsSDKManager.Instance.LoadSplashAd(); + return; + } + + // 展示热启动开屏 + AdsSDKManager.Instance.ShowSplashAd(); + } + else + { + // 冷启动 + // 首次启动 + var isNew = PlayerPrefsUtils.GetPlayerPrefsInt("Firstcold_Splash_Switch", 0) == 0; + // 首次冷启动开关 + var isFirstShow = GetSplashConfigItem().firstcold_splash_switch == 1; + // 冷启动开关 + var coldSplashSwitch = GetSplashConfigItem().cold_splash_switch == 1; + LoggerUtils.Debug(" [AppOpen] 冷启动 开关:" + coldSplashSwitch + " 首次启动是否展示开屏:" + isFirstShow + " 新用户:" + isNew); + // 新用户首次启动 + if (isNew) + { + PlayerPrefsUtils.SavePlayerPrefsInt("Firstcold_Splash_Switch", 1); + if (!isFirstShow) + { + // 新用户首次不展示 + AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke(); + } + else + { + // 新用户首次展示 + if (AdsSDKManager.Instance.IsSplashAvailable()) + { + AdsSDKManager.Instance.ShowSplashAd(); + } + else + { + AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke(); + AdsSDKManager.Instance.LoadSplashAd(); + LoggerUtils.Debug(" [AppOpen] 冷启动广告未准备好"); + } + } + } + else + { + // 非首次启动 + if (coldSplashSwitch) + { + // 展示冷启动 + if (AdsSDKManager.Instance.IsSplashAvailable()) + { + AdsSDKManager.Instance.ShowSplashAd(); + } + else + { + AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke(); + AdsSDKManager.Instance.LoadSplashAd(); + } + } + else + { + AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke(); + } + } + AppStateEventNotifier.AppStateChanged += OnAppStateChanged; + } + } + + private static string Splash_AD_RULES = "Splash_AD_RULES"; + private static string Splash_AD_RULES_DEFAULT_VALUE = "[{\"firstcold_splash_switch\":1,\"cold_splash_switch\":1,\"hot_splash_switch\":1,\"hot_timegap\":30,\"loadtime\":5}]"; + + public SplashConfigItem GetSplashConfigItem() + { + string jsonData = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString(Splash_AD_RULES, Splash_AD_RULES_DEFAULT_VALUE); + SplashConfigItem[] configItems = DataUtils.FromJsonArray(jsonData); + if (configItems.Length == 0 || configItems == null) + { + return new SplashConfigItem() { firstcold_splash_switch = 1, cold_splash_switch = 1, hot_splash_switch = 1, hot_timegap = 30, loadtime = 5 }; + } + else + { + return configItems[0]; + } + + } + + [System.Serializable] + public class SplashConfigItem + { + public int firstcold_splash_switch; + public int cold_splash_switch; + public int hot_splash_switch; + public int hot_timegap; + public int loadtime; + } + } +} + + diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdsSplashManager.cs.meta b/Assets/Script/SDKManager/AdsSDKManager/AdsSplashManager.cs.meta new file mode 100644 index 0000000..97634fd --- /dev/null +++ b/Assets/Script/SDKManager/AdsSDKManager/AdsSplashManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ad8d5f86e3dbf4c9986fcd1981e0be68 \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoAdsManager.cs b/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoAdsManager.cs index cec80e5..3e916d7 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoAdsManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoAdsManager.cs @@ -2,16 +2,10 @@ using System; using System.Collections; using System.Collections.Generic; using BigoAds.Scripts.Api; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; -using Unity.VisualScripting; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.BigoAdsManager +namespace WZ { public class BigoAdsManager : NormalSingleton, IAdService { diff --git a/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoInterstitialAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoInterstitialAdManager.cs index 135bec5..7f81ab5 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoInterstitialAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoInterstitialAdManager.cs @@ -2,13 +2,9 @@ using System; using System.Collections; using System.Collections.Generic; using BigoAds.Scripts.Api; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.BigoAdsManager +namespace WZ { public class BigoInterstitialAdManager diff --git a/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoRewardedAdManager.cs b/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoRewardedAdManager.cs index f0018bc..9a5c558 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoRewardedAdManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/BigoAdsManager/BigoRewardedAdManager.cs @@ -2,12 +2,9 @@ using System; using System.Collections; using System.Collections.Generic; using BigoAds.Scripts.Api; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.BigoAdsManager +namespace WZ { public class BigoRewardedAdManager diff --git a/Assets/Script/SDKManager/AdsSDKManager/Constant/AdsType.cs b/Assets/Script/SDKManager/AdsSDKManager/Constant/AdsType.cs index 3871075..e1e1922 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Constant/AdsType.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Constant/AdsType.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Constant +namespace WZ { public enum AdsType { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Constant/BannerAlignType.cs b/Assets/Script/SDKManager/AdsSDKManager/Constant/BannerAlignType.cs index 750dd3c..8faed6d 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Constant/BannerAlignType.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Constant/BannerAlignType.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Constant +namespace WZ { public enum BannerAliignType { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Constant/IvType.cs b/Assets/Script/SDKManager/AdsSDKManager/Constant/IvType.cs index 3d0fbc0..abd2a6d 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Constant/IvType.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Constant/IvType.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Constant +namespace WZ { public enum IvType { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Constant/PlatformType.cs b/Assets/Script/SDKManager/AdsSDKManager/Constant/PlatformType.cs index 10214a4..b86b606 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Constant/PlatformType.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Constant/PlatformType.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Constant +namespace WZ { public enum PlatformType { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsActionEvents.cs b/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsActionEvents.cs index 140a195..c3e2abc 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsActionEvents.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsActionEvents.cs @@ -1,9 +1,9 @@ using System.Collections; using System.Collections.Generic; -using Script.SDKManager.AdsSDKManager.Constant; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents + +namespace WZ { public class AdsActionEvents { @@ -14,12 +14,12 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents public static void TrackAdClosed(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat, string posotion, double value) { - + AdsSDKManager.Instance.otherAdsOnShow = false; } public static void TrackAdStartLoad(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat) { - + AdsSDKManager.Instance.otherAdsOnShow = true; } public static void TrackAdLoaded(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat, double loadTime) @@ -33,18 +33,18 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents public static void TrackAdFailToShow(PlatformType adPlatform, AdsType adFormat, string reason, string pos) { - + AdsSDKManager.Instance.otherAdsOnShow = false; } public static void TrackAdPosition(AdsType adFormat, string pos) { } - + public static void TrackAdImpression(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat, string posotion, double value) { } - + } -} +} \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsKeyEvents.cs b/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsKeyEvents.cs index c118850..6b59108 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsKeyEvents.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Events/AdsEvents/AdsKeyEvents.cs @@ -2,13 +2,10 @@ using System.Collections; using System.Collections.Generic; using Firebase.Analytics; using Newtonsoft.Json; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; -using Unity.VisualScripting.Antlr3.Runtime; + using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents +namespace WZ { public class AdsKeyEvents : NormalSingleton { diff --git a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InitResultCallbackImpl.cs b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InitResultCallbackImpl.cs index f6416f4..defee7b 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InitResultCallbackImpl.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InitResultCallbackImpl.cs @@ -1,16 +1,19 @@ using UnityEngine; -public class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback +namespace WZ { - public void OnSuccess() + public class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback { - Debug.Log("快手广告初始化成功"); - KwaiAdsManager.Instance.LoadRewardAd(); - KwaiAdsManager.Instance.LoadInterstitialAd(); - } + public void OnSuccess() + { + Debug.Log("快手广告初始化成功"); + KwaiAdsManager.Instance.LoadRewardAd(); + KwaiAdsManager.Instance.LoadInterstitialAd(); + } - public void OnFail(int code, string msg) - { - Debug.LogFormat($"快手广告初始化失败 code is {code}, msg:{msg}"); + public void OnFail(int code, string msg) + { + Debug.LogFormat($"快手广告初始化失败 code is {code}, msg:{msg}"); + } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdListener.cs b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdListener.cs index 90622fa..c9feb0d 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdListener.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdListener.cs @@ -1,31 +1,33 @@ using KwaiAds.Scripts.Api.Interstitial; using UnityEngine; - -public class InterstitialAdListener : IInterstitialAdListener +namespace WZ { - public void OnAdClick() + public class InterstitialAdListener : IInterstitialAdListener { - // 插页广告调整转换页 | Interstitial ad agjust conversion page - } + public void OnAdClick() + { + // 插页广告调整转换页 | Interstitial ad agjust conversion page + } - public void OnAdClose() - { - // 插页广告关闭 | Interstitial ad close - } + public void OnAdClose() + { + // 插页广告关闭 | Interstitial ad close + } - public void OnAdPlayComplete() - { - // 插页视频播放完成 | Interstitial video play complete - KwaiAdsManager.Instance.OnInterstitialCallback(); - } + public void OnAdPlayComplete() + { + // 插页视频播放完成 | Interstitial video play complete + KwaiAdsManager.Instance.OnInterstitialCallback(); + } - public void OnAdShow() - { - // 插页视频曝光 | Interstitial video show - } + public void OnAdShow() + { + // 插页视频曝光 | Interstitial video show + } - public void OnAdShowFailed(int code, string msg) - { - Debug.LogError($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}"); + public void OnAdShowFailed(int code, string msg) + { + Debug.LogError($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}"); + } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdLoadListener.cs b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdLoadListener.cs index 36fa2aa..033e510 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdLoadListener.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/InterstitialAdLoadListener.cs @@ -2,35 +2,38 @@ using KwaiAds.Scripts.Api.Interstitial; using UnityEngine; -public class InterstitialAdLoadListener : IInterstitialAdLoadListener +namespace WZ { - private const int maxLoadCount = 3; - private int currentLoadCount = 0; - - public void OnAdLoadFailed(string trackId, int code, string msg) + public class InterstitialAdLoadListener : IInterstitialAdLoadListener { - // 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white. - Debug.LogFormat($"InterstitialAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}"); - currentLoadCount++; - if (currentLoadCount < maxLoadCount) + private const int maxLoadCount = 3; + private int currentLoadCount = 0; + + public void OnAdLoadFailed(string trackId, int code, string msg) { - KwaiAdsManager.Instance.LoadRewardAd(); + // 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white. + Debug.LogFormat($"InterstitialAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}"); + currentLoadCount++; + if (currentLoadCount < maxLoadCount) + { + KwaiAdsManager.Instance.LoadRewardAd(); + } } - } - public void OnAdLoadStart(string trackId) - { - Debug.Log($"InterstitialAdLoadListener#OnAdLoadStart , trackId:{trackId}"); - } - - public void OnAdLoadSuccess(string trackId, string price) - { - // price 单位是$(美元,ecpm) | price in $ (dollars, ecpm) - Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}"); - if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result)) + public void OnAdLoadStart(string trackId) { - KwaiAdsManager.Instance.interstitiaAdRevenue = result; + Debug.Log($"InterstitialAdLoadListener#OnAdLoadStart , trackId:{trackId}"); + } + + public void OnAdLoadSuccess(string trackId, string price) + { + // price 单位是$(美元,ecpm) | price in $ (dollars, ecpm) Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}"); + if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result)) + { + KwaiAdsManager.Instance.interstitiaAdRevenue = result; + Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}"); + } } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/KwaiAdsManager.cs b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/KwaiAdsManager.cs index 7204845..c14d4ac 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/KwaiAdsManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/KwaiAdsManager.cs @@ -2,130 +2,131 @@ using System.Collections; using System.Collections.Generic; using KwaiAds.Scripts.Api.Interstitial; using KwaiAds.Scripts.Api.Reward; -using Script.SDKManager.AdsSDKManager.BigoAdsManager; -using Script.Utils; using UnityEngine; -public class KwaiAdsManager : NormalSingleton +namespace WZ { - //目前都是测试id - private const string appId = "899999"; - private const string token = "EaCw0AipSYyvf3E7"; - private const string rewardAdUnitId = "8999996001"; - private const string interstitialAdUnitId = "8999996002"; - - /// - /// 目前是千倍广告价值 - /// - public double rewardAdRevenue = 0; - /// - /// 插屏奖励价值 如果有竞价功能可能会用到 - /// - public double interstitiaAdRevenue = 0; - - private IRewardAdController rewardAdController; - private IInterstitialAdController interstitialAdController; - - public void Init() + public class KwaiAdsManager : NormalSingleton { - bool debug = true; // Whether in debug mode. Plsease set to false when in release build. - var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder() - .SetAppId(appId) - .SetToken(token) - .SetAppName("App Name") // Optional - .SetDebugLog(debug) // Optional - .Build(); - - KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl()); - } + //目前都是测试id + private const string appId = "899999"; + private const string token = "EaCw0AipSYyvf3E7"; + private const string rewardAdUnitId = "8999996001"; + private const string interstitialAdUnitId = "8999996002"; - #region 激励广告 + /// + /// 目前是千倍广告价值 + /// + public double rewardAdRevenue = 0; + /// + /// 插屏奖励价值 如果有竞价功能可能会用到 + /// + public double interstitiaAdRevenue = 0; - /// - /// 加载激励广告 - /// - public void LoadRewardAd() - { - if (rewardAdController != null) + private IRewardAdController rewardAdController; + private IInterstitialAdController interstitialAdController; + + public void Init() { - rewardAdController.Destroy(); - rewardAdController = null; - rewardAdRevenue = 0; + bool debug = true; // Whether in debug mode. Plsease set to false when in release build. + var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder() + .SetAppId(appId) + .SetToken(token) + .SetAppName("App Name") // Optional + .SetDebugLog(debug) // Optional + .Build(); + + KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl()); } - - rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController(); - KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(rewardAdUnitId); - rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener()); - } - /// - /// 展示激励广告 - /// - public void ShowRewardAd() - { - if (rewardAdController != null) + #region 激励广告 + + /// + /// 加载激励广告 + /// + public void LoadRewardAd() { - rewardAdController.Show(); + if (rewardAdController != null) + { + rewardAdController.Destroy(); + rewardAdController = null; + rewardAdRevenue = 0; + } + + rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController(); + KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(rewardAdUnitId); + rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener()); } - else + + /// + /// 展示激励广告 + /// + public void ShowRewardAd() { + if (rewardAdController != null) + { + rewardAdController.Show(); + } + else + { + LoadRewardAd(); + } + } + + /// + /// 广告播放完成 获得奖励 + /// + public void OnRewardAdCallback() + { + AdsSDKManager.Instance.OnRewardAdCallback(rewardAdRevenue); LoadRewardAd(); } - } - /// - /// 广告播放完成 获得奖励 - /// - public void OnRewardAdCallback() - { - AdsSDKManager.Instance.OnRewardAdCallback(rewardAdRevenue); - LoadRewardAd(); - } + #endregion - #endregion + #region 插屏 - #region 插屏 - - public void LoadInterstitialAd() - { - if (interstitialAdController != null) + public void LoadInterstitialAd() { - interstitialAdController.Destroy(); - interstitialAdController = null; - interstitiaAdRevenue = 0; + if (interstitialAdController != null) + { + interstitialAdController.Destroy(); + interstitialAdController = null; + interstitiaAdRevenue = 0; + } + + interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController(); + KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(interstitialAdUnitId); + interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener()); } - - interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController(); - KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(interstitialAdUnitId); - interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener()); - } - public void ShowInterstitialAd() - { - if (interstitialAdController != null) + public void ShowInterstitialAd() { - interstitialAdController.Show(); + if (interstitialAdController != null) + { + interstitialAdController.Show(); + } + else + { + LoadInterstitialAd(); + } } - else + + /// + /// 广告播放完成 获得奖励 + /// + public void OnInterstitialCallback() { + if (AdsSDKManager.Instance.IsMoreAdsBidding) + { + AdsSDKManager.Instance.OnRewardAdCallback(interstitiaAdRevenue); + } + LoadInterstitialAd(); } - } - - /// - /// 广告播放完成 获得奖励 - /// - public void OnInterstitialCallback() - { - if (AdsSDKManager.Instance.IsMoreAdsBidding) - { - AdsSDKManager.Instance.OnRewardAdCallback(interstitiaAdRevenue); - } - - LoadInterstitialAd(); + + #endregion + } - #endregion - -} - +} \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdListener.cs b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdListener.cs index fea4ab4..d999e9a 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdListener.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdListener.cs @@ -1,37 +1,40 @@ using KwaiAds.Scripts.Api.Reward; using UnityEngine; -public class RewardAdListener : IRewardAdListener +namespace WZ { - public void OnAdClick() + public class RewardAdListener : IRewardAdListener { - // 激励广告调整转换页 | Reward ad adjustment conversion page - } + public void OnAdClick() + { + // 激励广告调整转换页 | Reward ad adjustment conversion page + } - public void OnAdClose() - { - // 激励广告关闭 | Reward ad close - KwaiAdsManager.Instance.LoadRewardAd(); - } + public void OnAdClose() + { + // 激励广告关闭 | Reward ad close + KwaiAdsManager.Instance.LoadRewardAd(); + } - public void OnAdPlayComplete() - { - // 激励视频播放完成 | Reward video play complete - } + public void OnAdPlayComplete() + { + // 激励视频播放完成 | Reward video play complete + } - public void OnAdShow() - { - // 激励视频曝光 | Reward video show - } + public void OnAdShow() + { + // 激励视频曝光 | Reward video show + } - public void OnAdShowFailed(int code, string msg) - { - Debug.LogFormat($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}"); - } + public void OnAdShowFailed(int code, string msg) + { + Debug.LogFormat($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}"); + } - public void OnRewardEarned() - { - // 获取到激励 | Reward earned - KwaiAdsManager.Instance.OnRewardAdCallback(); + public void OnRewardEarned() + { + // 获取到激励 | Reward earned + KwaiAdsManager.Instance.OnRewardAdCallback(); + } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdLoadListener.cs b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdLoadListener.cs index 1598d9f..1fda4c2 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdLoadListener.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/KwaiAdsManager/RewardAdLoadListener.cs @@ -2,34 +2,37 @@ using KwaiAds.Scripts.Api.Reward; using UnityEngine; -public class RewardAdLoadListener : IRewardAdLoadListener +namespace WZ { - private const int maxLoadCount = 3; - private int currentLoadCount = 0; - - public void OnAdLoadFailed(string trackId, int code, string msg) + public class RewardAdLoadListener : IRewardAdLoadListener { - // 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white. - Debug.LogFormat($"RewardAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}"); - currentLoadCount++; - if (currentLoadCount < maxLoadCount) + private const int maxLoadCount = 3; + private int currentLoadCount = 0; + + public void OnAdLoadFailed(string trackId, int code, string msg) { - KwaiAdsManager.Instance.LoadRewardAd(); + // 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white. + Debug.LogFormat($"RewardAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}"); + currentLoadCount++; + if (currentLoadCount < maxLoadCount) + { + KwaiAdsManager.Instance.LoadRewardAd(); + } } - } - public void OnAdLoadStart(string trackId) - { - Debug.Log($"RewardAdLoadListener#OnAdLoadStart , trackId:{trackId}"); - } - - public void OnAdLoadSuccess(string trackId, string price) - { - // price 单位是$(美元,ecpm) | price in $ (dollars, ecpm) - if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result)) + public void OnAdLoadStart(string trackId) { - KwaiAdsManager.Instance.rewardAdRevenue = result; - Debug.Log($"RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}"); + Debug.Log($"RewardAdLoadListener#OnAdLoadStart , trackId:{trackId}"); + } + + public void OnAdLoadSuccess(string trackId, string price) + { + // price 单位是$(美元,ecpm) | price in $ (dollars, ecpm) + if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result)) + { + KwaiAdsManager.Instance.rewardAdRevenue = result; + Debug.Log($"RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}"); + } } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/MaxAdsManager/MaxAdsManager.cs b/Assets/Script/SDKManager/AdsSDKManager/MaxAdsManager/MaxAdsManager.cs index a85bb4d..dca4e92 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/MaxAdsManager/MaxAdsManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/MaxAdsManager/MaxAdsManager.cs @@ -4,14 +4,9 @@ using System.Collections.Generic; using System.Linq; using System.Net.Security; using Firebase.Analytics; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.MaxAdsManager +namespace WZ { public class MaxAdsManager : NormalSingleton, IAdService { diff --git a/Assets/Script/SDKManager/AdsSDKManager/TpnAdsManager/TpnAdsManager.cs b/Assets/Script/SDKManager/AdsSDKManager/TpnAdsManager/TpnAdsManager.cs index 6900bcc..a49c63c 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/TpnAdsManager/TpnAdsManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/TpnAdsManager/TpnAdsManager.cs @@ -5,15 +5,9 @@ using System.Linq; using System.Threading; using AnyThinkAds.Api; using AnyThinkAds.ThirdParty.LitJson; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.SDKManager.AdsSDKManager.Utils; -using Script.Utils; -using SDKManager.AdsSDKManager.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.TpnAdsManager +namespace WZ { public class TpnAdsManager : NormalSingleton, IAdService { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdConfigParser.cs b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdConfigParser.cs index dad302e..bfc9613 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdConfigParser.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdConfigParser.cs @@ -1,11 +1,10 @@ using System; using System.Collections; using System.Collections.Generic; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.Utils; + using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Utils +namespace WZ { public static class AdConfigParser { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdPlayCountManager.cs b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdPlayCountManager.cs index c5beadb..1957d5f 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdPlayCountManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdPlayCountManager.cs @@ -1,11 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.Utils; using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Utils +namespace WZ { public class AdPlayCountManager { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs index a32d053..847a2bf 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs @@ -1,10 +1,9 @@ using System.Collections; using System.Collections.Generic; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.Utils; + using UnityEngine; -namespace Script.SDKManager.AdsSDKManager.Utils +namespace WZ { public struct AdPriceInfo { diff --git a/Assets/Script/SDKManager/AdsSDKManager/Utils/BidPlatformManager.cs b/Assets/Script/SDKManager/AdsSDKManager/Utils/BidPlatformManager.cs index 2bb7eb4..483def6 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Utils/BidPlatformManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Utils/BidPlatformManager.cs @@ -1,11 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; -using Script.Utils; using UnityEngine; -using Script.SDKManager.AdsSDKManager.Constant; -namespace Script.SDKManager.AdsSDKManager.Utils +namespace WZ { [Serializable] public class AdTypeBidState diff --git a/Assets/Script/SDKManager/AdsSDKManager/Utils/ThreadUtils.cs b/Assets/Script/SDKManager/AdsSDKManager/Utils/ThreadUtils.cs index 01b4c2b..ac89add 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Utils/ThreadUtils.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Utils/ThreadUtils.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading; using UnityEngine; -namespace SDKManager.AdsSDKManager.Utils +namespace WZ { public class ThreadUtils : MonoBehaviour { diff --git a/Assets/Script/SDKManager/AppSDKManager.cs b/Assets/Script/SDKManager/AppSDKManager.cs index 313bed8..56c2627 100644 --- a/Assets/Script/SDKManager/AppSDKManager.cs +++ b/Assets/Script/SDKManager/AppSDKManager.cs @@ -4,10 +4,8 @@ using System.Collections.Generic; using EFSDK; using Firebase.RemoteConfig; using Newtonsoft.Json; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.Utils; using UnityEngine; +using WZ; public class AppSDKManager : MonoBehaviour { @@ -23,10 +21,15 @@ public class AppSDKManager : MonoBehaviour FireBaseSDKManager.Instance.Init(); AdjustManager.Instance.Init(); ShuShuMangage.Instance.Init(); - AdsSDKManager.Instance.InitSDK(); + EFSdkManager.Instance.Init(); } + public void Init(Action action) + { + AdsSDKManager.Instance.InitSDK(action); + } + /// /// 协程 /// diff --git a/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs b/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs index 1379b17..03bcf93 100644 --- a/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs +++ b/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs @@ -1,46 +1,48 @@ using EFSDK; using Firebase.Analytics; -using Script.Utils; using UnityEngine; -public class EFSdkManager : NormalSingleton +namespace WZ { - public void Init() + public class EFSdkManager : NormalSingleton { - EFSdk.get().Init((actionType, str) => + public void Init() { - if (EFSdk.ActionType.COIN_CLICK == actionType) + EFSdk.get().Init((actionType, str) => { - //TOTO 游戏在此处理 点击金币弹广告的逻辑或其他 - } - if (EFSdk.ActionType.BALLOON_CLICK == actionType) - { - //TOTO 游戏在此处理 点击宝箱弹广告的逻辑或其他 - } - if (EFSdk.ActionType.COIN_SHOW == actionType) - { - - } - if (EFSdk.ActionType.BOX_SHOW == actionType) - { - - } - if (EFSdk.ActionType.GAM_LOAD_SUCC == actionType) - { - // 标签id,标识哪个WebView加载成功了 - int id = int.Parse(str); - } - }); + if (EFSdk.ActionType.COIN_CLICK == actionType) + { + //TOTO 游戏在此处理 点击金币弹广告的逻辑或其他 + } + if (EFSdk.ActionType.BALLOON_CLICK == actionType) + { + //TOTO 游戏在此处理 点击宝箱弹广告的逻辑或其他 + } + if (EFSdk.ActionType.COIN_SHOW == actionType) + { - SetSDKEventCallback(); - } + } + if (EFSdk.ActionType.BOX_SHOW == actionType) + { - private void SetSDKEventCallback() - { - EFSdk.get().SetSDKEventCallback((eventName, dict) => + } + if (EFSdk.ActionType.GAM_LOAD_SUCC == actionType) + { + // 标签id,标识哪个WebView加载成功了 + int id = int.Parse(str); + } + }); + + SetSDKEventCallback(); + } + + private void SetSDKEventCallback() { - FireBaseAnalyticsManager.Instance.LogEvent(eventName, dict); - ShuShuEvent.Instance.Track(eventName, dict); - }); + EFSdk.get().SetSDKEventCallback((eventName, dict) => + { + FireBaseAnalyticsManager.Instance.LogEvent(eventName, dict); + ShuShuEvent.Instance.Track(eventName, dict); + }); + } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/FirebaseManager/FireBaseAnalyticsManager.cs b/Assets/Script/SDKManager/FirebaseManager/FireBaseAnalyticsManager.cs index 1fc2b76..708b304 100644 --- a/Assets/Script/SDKManager/FirebaseManager/FireBaseAnalyticsManager.cs +++ b/Assets/Script/SDKManager/FirebaseManager/FireBaseAnalyticsManager.cs @@ -3,114 +3,112 @@ using System; using System.Collections.Generic; using Firebase.Analytics; using Newtonsoft.Json; -using Script.Common; -using Script.SDKManager.AdsSDKManager.Constant; -using Script.SDKManager.AdsSDKManager.Events.AdsEvents; -using Script.Utils; -/// -/// Firebase analytics事件上报 -/// -public class FireBaseAnalyticsManager : NormalSingleton +namespace WZ { - private const string KEY_SUPER_PROPERTIES = "KEY_SUPER_PROPERTIES"; - - private Dictionary superProperties = new Dictionary(); + /// + /// Firebase analytics事件上报 + /// + public class FireBaseAnalyticsManager : NormalSingleton + { + private const string KEY_SUPER_PROPERTIES = "KEY_SUPER_PROPERTIES"; - public void InitSuperProperties() - { - string json = PlayerPrefsUtils.GetPlayerPrefsString(KEY_SUPER_PROPERTIES, ""); - if (!string.IsNullOrEmpty(json)) + private Dictionary superProperties = new Dictionary(); + + public void InitSuperProperties() { - superProperties = JsonConvert.DeserializeObject>(json); - } - } - - - public void LogEvent(string eventName) - { - List parameterList = new List(); - if (superProperties != null) - { - foreach (var superProperty in superProperties) + string json = PlayerPrefsUtils.GetPlayerPrefsString(KEY_SUPER_PROPERTIES, ""); + if (!string.IsNullOrEmpty(json)) { - Parameter parameter = new Parameter(superProperty.Key, superProperty.Value.ToString()); - parameterList.Add(parameter); + superProperties = JsonConvert.DeserializeObject>(json); } } - - FirebaseAnalytics.LogEvent(eventName, parameterList.ToArray()); - } - - public void LogEvent(string eventName, Dictionary dict) - { - List parameters = new List(); - foreach (var item in dict) - { - Parameter parameter = new Parameter(item.Key, item.Value); - parameters.Add(parameter); - } - Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameters.ToArray()); - } - /// - /// 设置用户属性 - /// - /// - /// - public void SetUserProperty(string name, string property) - { - Firebase.Analytics.FirebaseAnalytics.SetUserProperty(name, property); - } - - /// - /// 设置用户属性 - /// - /// - /// - public void SetUserProperty(Dictionary propertys) - { - foreach (var property in propertys) - { - SetUserProperty(property.Key, property.Value.ToString()); - } - - } - /// - /// 设置公共事件属性 - /// - /// - public void SetSuperProperties(Dictionary propertys) - { - if (superProperties == null) + public void LogEvent(string eventName) { - superProperties = new Dictionary(); + List parameterList = new List(); + if (superProperties != null) + { + foreach (var superProperty in superProperties) + { + Parameter parameter = new Parameter(superProperty.Key, superProperty.Value.ToString()); + parameterList.Add(parameter); + } + } + + FirebaseAnalytics.LogEvent(eventName, parameterList.ToArray()); } - foreach (var property in propertys) + public void LogEvent(string eventName, Dictionary dict) { - superProperties[property.Key] = property.Value; + List parameters = new List(); + foreach (var item in dict) + { + Parameter parameter = new Parameter(item.Key, item.Value); + parameters.Add(parameter); + } + Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameters.ToArray()); + } + + /// + /// 设置用户属性 + /// + /// + /// + public void SetUserProperty(string name, string property) + { + Firebase.Analytics.FirebaseAnalytics.SetUserProperty(name, property); + } + + /// + /// 设置用户属性 + /// + /// + /// + public void SetUserProperty(Dictionary propertys) + { + foreach (var property in propertys) + { + SetUserProperty(property.Key, property.Value.ToString()); + } + + } + + /// + /// 设置公共事件属性 + /// + /// + public void SetSuperProperties(Dictionary propertys) + { + if (superProperties == null) + { + superProperties = new Dictionary(); + } + + foreach (var property in propertys) + { + superProperties[property.Key] = property.Value; + } + + string json = JsonConvert.SerializeObject(superProperties); + PlayerPrefsUtils.SavePlayerPrefsString(KEY_SUPER_PROPERTIES, json); } - - string json = JsonConvert.SerializeObject(superProperties); - PlayerPrefsUtils.SavePlayerPrefsString(KEY_SUPER_PROPERTIES, json); - } - /// - /// FireBase收益上报 - /// - /// 聚合平台名称 - /// 广告平台名称 - /// 广告位ID - /// 广告格式 - /// 单次展示收益 - /// 广告展示点位 - /// 第几次展示该格式的广告 - public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, AdsType ad_format, double revenue, string position, int number) - { - var impressionParameters = new[] { + /// + /// FireBase收益上报 + /// + /// 聚合平台名称 + /// 广告平台名称 + /// 广告位ID + /// 广告格式 + /// 单次展示收益 + /// 广告展示点位 + /// 第几次展示该格式的广告 + public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, AdsType ad_format, double revenue, string position, int number) + { + var impressionParameters = new[] { new Firebase.Analytics.Parameter("ad_platform", ad_platform), new Firebase.Analytics.Parameter("ad_source", ad_source), new Firebase.Analytics.Parameter("ad_unit_name",ad_unit_name), @@ -121,50 +119,51 @@ public class FireBaseAnalyticsManager : NormalSingleton - /// 收益分离 - /// - /// - private string GetName() - { - string name = "ad_impression"; - //获取在线参数 - string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_fir"); - if (string.IsNullOrEmpty(json)) - { - return name; - } - var revenueAdjs = JsonConvert.DeserializeObject(json); - if (revenueAdjs == null && revenueAdjs.Length == 0) - { - return name; + string name = GetName(); + Firebase.Analytics.FirebaseAnalytics.LogEvent(name, impressionParameters); + AdsKeyEvents.Instance.LogAdCountEvents(ad_format, revenue); } - int totalRate = 0; - //获取全部概率 - foreach (var item in revenueAdjs) + /// + /// 收益分离 + /// + /// + private string GetName() { - totalRate += item.rate; - } - //开始随机 - int randomValue = UnityEngine.Random.Range(0, totalRate); - int accumulatedRate = 0; - - //根据随机值定位 - foreach (var item in revenueAdjs) - { - accumulatedRate += item.rate; - if (randomValue < accumulatedRate) + string name = "ad_impression"; + //获取在线参数 + string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_fir"); + if (string.IsNullOrEmpty(json)) { - return item.name; + return name; + } + var revenueAdjs = JsonConvert.DeserializeObject(json); + if (revenueAdjs == null && revenueAdjs.Length == 0) + { + return name; } - } - return name; + int totalRate = 0; + //获取全部概率 + foreach (var item in revenueAdjs) + { + totalRate += item.rate; + } + //开始随机 + int randomValue = UnityEngine.Random.Range(0, totalRate); + int accumulatedRate = 0; + + //根据随机值定位 + foreach (var item in revenueAdjs) + { + accumulatedRate += item.rate; + if (randomValue < accumulatedRate) + { + return item.name; + } + } + + return name; + } } -} +} \ No newline at end of file diff --git a/Assets/Script/SDKManager/FirebaseManager/FireBaseRemoteConfigManager.cs b/Assets/Script/SDKManager/FirebaseManager/FireBaseRemoteConfigManager.cs index 9b4d45d..2208a33 100644 --- a/Assets/Script/SDKManager/FirebaseManager/FireBaseRemoteConfigManager.cs +++ b/Assets/Script/SDKManager/FirebaseManager/FireBaseRemoteConfigManager.cs @@ -2,218 +2,219 @@ using System.Globalization; using Firebase.Extensions; using Firebase.RemoteConfig; -using Script.Utils; -using SDK.Utils; using UnityEngine; -public class FireBaseRemoteConfigManager : NormalSingleton +namespace WZ { - public void FetchRemoteConfig() + public class FireBaseRemoteConfigManager : NormalSingleton { - Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => + public void FetchRemoteConfig() { - if (task.Result == Firebase.DependencyStatus.Available) + Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => { - Firebase.RemoteConfig.FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task => + if (task.Result == Firebase.DependencyStatus.Available) { - FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task => + Firebase.RemoteConfig.FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task => { - // adjust卸载监控 - - /* 执行到这时,表示firebase接入正常,能获取到远端在线参数 */ - - // 设置 firebase 初始化成功 flag - - // 初始化广告 - - // 检查Adjust归因 + FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task => + { + // adjust卸载监控 + + /* 执行到这时,表示firebase接入正常,能获取到远端在线参数 */ + + // 设置 firebase 初始化成功 flag + + // 初始化广告 + + // 检查Adjust归因 + }); }); - }); - } - }); - } - - - /// - /// 获取int参数 - /// - /// - /// - /// - public int GetRemoteConfigInt(string key, int defaultValue = 0, bool IsEncrypt = false) - { - try - { - string newKey = GetKey(key, IsEncrypt); - // 获取值 - var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); - - if (configValue.Source == ValueSource.RemoteValue) - { - int value = (int)GetValueLong(newKey, configValue); - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {value}, No Is defaultValue"); - return value; - } - else - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - return defaultValue; - } + } + }); } - catch (Exception e) - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); - return defaultValue; - } - - } - - /// - /// 获取string参数 - /// - /// - /// - /// - public string GetRemoteConfigString(string key, string defaultValue = "", bool IsEncrypt = false) - { - try - { - string newKey = GetKey(key, IsEncrypt); - // 获取值 - var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); - if (configValue.Source == ValueSource.RemoteValue) - { - string valueStr = GetValueStr(newKey, configValue); - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueStr}, No Is defaultValue"); - return valueStr; - } - else - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - return defaultValue; - } - } - catch (Exception e) - { - Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - return defaultValue; - } - - } - - /// - /// 获取bool参数 - /// - /// - /// - /// - public bool GetRemoteConfigBool(string key, bool defaultValue = false, bool IsEncrypt = false) - { - try - { - string newKey = GetKey(key, IsEncrypt); - // 获取值 - var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); - - if (configValue.Source == ValueSource.RemoteValue) - { - bool valueBool = GetValueBool(newKey, configValue); - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueBool}, No Is defaultValue"); - return valueBool; - } - else - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - return defaultValue; - } - } - catch (Exception e) - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); - return defaultValue; - } - - } - - /// - /// 获取float参数 - /// - /// - /// - /// - public float GetRemoteConfigFloat(string key, float defaultValue = 0, bool IsEncrypt = false) - { - try - { - string newKey = GetKey(key, IsEncrypt); - // 获取值 - var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); - - if (configValue.Source == ValueSource.RemoteValue) - { - float valueFloat = (float)GetValueDouble(newKey, configValue); - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueFloat}, No Is defaultValue"); - return valueFloat; - } - else - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - return defaultValue; - } - } - catch (Exception e) - { - LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); - Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); - return defaultValue; - } - - } - /// - /// 是否是加密 - /// - /// - private bool IsEncrypt(string key) - { - return key.StartsWith("CCB", StringComparison.OrdinalIgnoreCase); - } - private string GetKey(string key, bool isEncrypt) - { - //ccb开头 忽略大小写 - return isEncrypt ? $"ccb{EncryptionUtils.AesEncrypt(AppSDKManager.PackageName, key)}" : key; - } - - private string GetValueStr(string key, ConfigValue configValue) - { - return IsEncrypt(key) ? EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue) : configValue.StringValue; - } - - private long GetValueLong(string key, ConfigValue configValue) - { - return IsEncrypt(key) ? long.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.LongValue; - } - - private bool GetValueBool(string key, ConfigValue configValue) - { - return IsEncrypt(key) ? bool.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.BooleanValue; - } - - private double GetValueDouble(string key, ConfigValue configValue) - { - if (IsEncrypt(key)) + /// + /// 获取int参数 + /// + /// + /// + /// + public int GetRemoteConfigInt(string key, int defaultValue = 0, bool IsEncrypt = false) { - string valueStr = EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue); - if (float.TryParse(valueStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result)) + try { - return result; + string newKey = GetKey(key, IsEncrypt); + // 获取值 + var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); + + if (configValue.Source == ValueSource.RemoteValue) + { + int value = (int)GetValueLong(newKey, configValue); + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {value}, No Is defaultValue"); + return value; + } + else + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + return defaultValue; + } } + catch (Exception e) + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); + return defaultValue; + } + + } + + /// + /// 获取string参数 + /// + /// + /// + /// + public string GetRemoteConfigString(string key, string defaultValue = "", bool IsEncrypt = false) + { + try + { + string newKey = GetKey(key, IsEncrypt); + // 获取值 + var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); + if (configValue.Source == ValueSource.RemoteValue) + { + string valueStr = GetValueStr(newKey, configValue); + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueStr}, No Is defaultValue"); + return valueStr; + } + else + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + return defaultValue; + } + } + catch (Exception e) + { + Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + return defaultValue; + } + + } + + /// + /// 获取bool参数 + /// + /// + /// + /// + public bool GetRemoteConfigBool(string key, bool defaultValue = false, bool IsEncrypt = false) + { + try + { + string newKey = GetKey(key, IsEncrypt); + // 获取值 + var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); + + if (configValue.Source == ValueSource.RemoteValue) + { + bool valueBool = GetValueBool(newKey, configValue); + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueBool}, No Is defaultValue"); + return valueBool; + } + else + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + return defaultValue; + } + } + catch (Exception e) + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); + return defaultValue; + } + + } + + /// + /// 获取float参数 + /// + /// + /// + /// + public float GetRemoteConfigFloat(string key, float defaultValue = 0, bool IsEncrypt = false) + { + try + { + string newKey = GetKey(key, IsEncrypt); + // 获取值 + var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey); + + if (configValue.Source == ValueSource.RemoteValue) + { + float valueFloat = (float)GetValueDouble(newKey, configValue); + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueFloat}, No Is defaultValue"); + return valueFloat; + } + else + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + return defaultValue; + } + } + catch (Exception e) + { + LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue"); + Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}"); + return defaultValue; + } + + } + + /// + /// 是否是加密 + /// + /// + private bool IsEncrypt(string key) + { + return key.StartsWith("CCB", StringComparison.OrdinalIgnoreCase); + } + + private string GetKey(string key, bool isEncrypt) + { + //ccb开头 忽略大小写 + return isEncrypt ? $"ccb{EncryptionUtils.AesEncrypt(AppSDKManager.PackageName, key)}" : key; + } + + private string GetValueStr(string key, ConfigValue configValue) + { + return IsEncrypt(key) ? EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue) : configValue.StringValue; + } + + private long GetValueLong(string key, ConfigValue configValue) + { + return IsEncrypt(key) ? long.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.LongValue; + } + + private bool GetValueBool(string key, ConfigValue configValue) + { + return IsEncrypt(key) ? bool.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.BooleanValue; + } + + private double GetValueDouble(string key, ConfigValue configValue) + { + if (IsEncrypt(key)) + { + string valueStr = EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue); + if (float.TryParse(valueStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result)) + { + return result; + } + } + + return configValue.DoubleValue; } - - return configValue.DoubleValue; } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/FirebaseManager/FireBaseSDKManager.cs b/Assets/Script/SDKManager/FirebaseManager/FireBaseSDKManager.cs index 895e9b4..b873fa3 100644 --- a/Assets/Script/SDKManager/FirebaseManager/FireBaseSDKManager.cs +++ b/Assets/Script/SDKManager/FirebaseManager/FireBaseSDKManager.cs @@ -3,19 +3,21 @@ using System.Collections; using System.Collections.Generic; using Firebase; using Firebase.RemoteConfig; -using Script.Utils; using UnityEngine; -public class FireBaseSDKManager : NormalSingleton +namespace WZ { - public void Init() + public class FireBaseSDKManager : NormalSingleton { - InitSDK(); - } + public void Init() + { + InitSDK(); + } - private void InitSDK() - { - FireBaseRemoteConfigManager.Instance.FetchRemoteConfig(); - FireBaseAnalyticsManager.Instance.InitSuperProperties(); + private void InitSDK() + { + FireBaseRemoteConfigManager.Instance.FetchRemoteConfig(); + FireBaseAnalyticsManager.Instance.InitSuperProperties(); + } } -} +} \ No newline at end of file diff --git a/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs b/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs index 5ee235c..6060af6 100644 --- a/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs +++ b/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs @@ -1,91 +1,93 @@ using System.Collections.Generic; using System.Linq; -using Script.Utils; using ThinkingData.Analytics; -public class ShuShuEvent : NormalSingleton +namespace WZ { - /// - /// 设置用户属性 - /// - public void UserSet(Dictionary dic) + public class ShuShuEvent : NormalSingleton { - TDAnalytics.UserSet(dic); - } + /// + /// 设置用户属性 + /// + public void UserSet(Dictionary dic) + { + TDAnalytics.UserSet(dic); + } - /// - /// 设置公共事件属性 - /// - /// - public void SetSuperProperties(Dictionary superProperties) - { - TDAnalytics.SetSuperProperties(superProperties);//设置公共事件属性 - } + /// + /// 设置公共事件属性 + /// + /// + public void SetSuperProperties(Dictionary superProperties) + { + TDAnalytics.SetSuperProperties(superProperties);//设置公共事件属性 + } - /// - /// 发送事件 - /// - public void Track(string eventName) - { - TDAnalytics.Track(eventName); - } - - /// - /// 发送事件 - /// - public void Track(string eventName, string key1, object value1) - { - var extraInfo = new Dictionary(); - if (key1 != null && value1 != null) - { - extraInfo[key1] = value1; - } + /// + /// 发送事件 + /// + public void Track(string eventName) + { + TDAnalytics.Track(eventName); + } - Track(eventName, extraInfo); - } - - /// - /// 发送事件 - /// - public void Track(string eventName, Dictionary properties) - { - TDAnalytics.Track(eventName, properties); - } - - /// - /// 发送事件 - /// - public void Track(string eventName, Dictionary properties) - { - var newProperties = properties.ToDictionary( - pair => pair.Key, - pair => (object)pair.Value - ); - TDAnalytics.Track(eventName, newProperties); - } - - /// - /// 数数收益上报 - /// - /// 聚合平台名称 - /// 广告平台名称 - /// 广告位ID - /// 广告格式 - /// 单次展示收益 - /// 广告展示点位 - /// 第几次展示该格式的广告 - public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number) - { - Dictionary properties = new Dictionary(); - properties.Add("ad_platform", ad_platform); - properties.Add("ad_source", ad_source); - properties.Add("ad_unit_name", ad_unit_name); - properties.Add("ad_format", ad_format); - properties.Add("value", revenue); - properties.Add("currency", "USD"); - properties.Add("position", position); - properties.Add("number", number); + /// + /// 发送事件 + /// + public void Track(string eventName, string key1, object value1) + { + var extraInfo = new Dictionary(); + if (key1 != null && value1 != null) + { + extraInfo[key1] = value1; + } - TDAnalytics.Track("ad_impression", properties); + Track(eventName, extraInfo); + } + + /// + /// 发送事件 + /// + public void Track(string eventName, Dictionary properties) + { + TDAnalytics.Track(eventName, properties); + } + + /// + /// 发送事件 + /// + public void Track(string eventName, Dictionary properties) + { + var newProperties = properties.ToDictionary( + pair => pair.Key, + pair => (object)pair.Value + ); + TDAnalytics.Track(eventName, newProperties); + } + + /// + /// 数数收益上报 + /// + /// 聚合平台名称 + /// 广告平台名称 + /// 广告位ID + /// 广告格式 + /// 单次展示收益 + /// 广告展示点位 + /// 第几次展示该格式的广告 + public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number) + { + Dictionary properties = new Dictionary(); + properties.Add("ad_platform", ad_platform); + properties.Add("ad_source", ad_source); + properties.Add("ad_unit_name", ad_unit_name); + properties.Add("ad_format", ad_format); + properties.Add("value", revenue); + properties.Add("currency", "USD"); + properties.Add("position", position); + properties.Add("number", number); + + TDAnalytics.Track("ad_impression", properties); + } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/ShuShuMangage/ShuShuMangage.cs b/Assets/Script/SDKManager/ShuShuMangage/ShuShuMangage.cs index 5be34c2..43fadc2 100644 --- a/Assets/Script/SDKManager/ShuShuMangage/ShuShuMangage.cs +++ b/Assets/Script/SDKManager/ShuShuMangage/ShuShuMangage.cs @@ -1,22 +1,23 @@ using System.Collections; using System.Collections.Generic; -using Script.Utils; using ThinkingData.Analytics; using UnityEngine; - -public class ShuShuMangage : NormalSingleton +namespace WZ { - private const string appid = "80f6819a81c743cbad667ecf242f3133"; - private const string server = "https://global-receiver-ta.thinkingdata.cn"; - - public void Init() + public class ShuShuMangage : NormalSingleton { - // 初始化SDK - TDAnalytics.Init(appid, server); - //开启自动采集事件 - TDAnalytics.EnableAutoTrack(TDAutoTrackEventType.AppInstall | TDAutoTrackEventType.AppStart | TDAutoTrackEventType.AppEnd); - //如果用户已登录,可以设置用户的账号ID作为身份唯一标识 - TDAnalytics.Login("TA"); - } + private const string appid = "80f6819a81c743cbad667ecf242f3133"; + private const string server = "https://global-receiver-ta.thinkingdata.cn"; -} + public void Init() + { + // 初始化SDK + TDAnalytics.Init(appid, server); + //开启自动采集事件 + TDAnalytics.EnableAutoTrack(TDAutoTrackEventType.AppInstall | TDAutoTrackEventType.AppStart | TDAutoTrackEventType.AppEnd); + //如果用户已登录,可以设置用户的账号ID作为身份唯一标识 + TDAnalytics.Login("TA"); + } + + } +} \ No newline at end of file diff --git a/Assets/Script/Test.cs b/Assets/Script/Test.cs index 91160fd..a1ad232 100644 --- a/Assets/Script/Test.cs +++ b/Assets/Script/Test.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; +using WZ; public class Test : MonoBehaviour { diff --git a/Assets/Script/Utils/DataUtils.cs b/Assets/Script/Utils/DataUtils.cs new file mode 100644 index 0000000..096569e --- /dev/null +++ b/Assets/Script/Utils/DataUtils.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WZ +{ + public static class DataUtils + { + [System.Serializable] + private class Wrapper + { + public T[] items; + } + + public static T[] FromJsonArray(string json) + { + string wrappedJson = $"{{\"items\":{json}}}"; + Wrapper wrapper = JsonUtility.FromJson>(wrappedJson); + return wrapper.items; + } + } +} + diff --git a/Assets/Script/Utils/DataUtils.cs.meta b/Assets/Script/Utils/DataUtils.cs.meta new file mode 100644 index 0000000..362c570 --- /dev/null +++ b/Assets/Script/Utils/DataUtils.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: be1bd83cd48f44fa59b93f7ee10ec4fc \ No newline at end of file diff --git a/Assets/Script/Utils/EncryptionUtils.cs b/Assets/Script/Utils/EncryptionUtils.cs index b57063a..b435a40 100644 --- a/Assets/Script/Utils/EncryptionUtils.cs +++ b/Assets/Script/Utils/EncryptionUtils.cs @@ -5,7 +5,7 @@ using System.Security.Cryptography; using System.Text; using UnityEngine; -namespace SDK.Utils +namespace WZ { public static class EncryptionUtils { diff --git a/Assets/Script/Utils/LoggerUtils.cs b/Assets/Script/Utils/LoggerUtils.cs index b715804..b065da7 100644 --- a/Assets/Script/Utils/LoggerUtils.cs +++ b/Assets/Script/Utils/LoggerUtils.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; -namespace Script.Utils +namespace WZ { public static class LoggerUtils { diff --git a/Assets/Script/Utils/PlayerPrefsUtils.cs b/Assets/Script/Utils/PlayerPrefsUtils.cs index 6382553..4311797 100644 --- a/Assets/Script/Utils/PlayerPrefsUtils.cs +++ b/Assets/Script/Utils/PlayerPrefsUtils.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.Utils +namespace WZ { public class PlayerPrefsUtils { diff --git a/Assets/Script/Utils/SingletonBase.cs b/Assets/Script/Utils/SingletonBase.cs index ef497eb..21f970b 100644 --- a/Assets/Script/Utils/SingletonBase.cs +++ b/Assets/Script/Utils/SingletonBase.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace Script.Utils +namespace WZ { public abstract class NormalSingleton where T : new() { diff --git a/Assets/Script/Utils/TimeUtils.cs b/Assets/Script/Utils/TimeUtils.cs index a94b203..da2b641 100644 --- a/Assets/Script/Utils/TimeUtils.cs +++ b/Assets/Script/Utils/TimeUtils.cs @@ -1,6 +1,6 @@ using System; -namespace Script.Utils +namespace WZ { public class TimeUtils { diff --git a/Assets/Script/Utils/TimerUtils.cs b/Assets/Script/Utils/TimerUtils.cs index caeeeff..49ee250 100644 --- a/Assets/Script/Utils/TimerUtils.cs +++ b/Assets/Script/Utils/TimerUtils.cs @@ -3,7 +3,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Script.Utils +namespace WZ { public class TimerUtils : MonoBehaviour {