Compare commits
No commits in common. "40226c370ff0decf8b51b4a340f583ed36d3d176" and "ca3ee52ee276fb0cb3a27982b272a3a7270ba287" have entirely different histories.
40226c370f
...
ca3ee52ee2
|
|
@ -6,6 +6,7 @@ using Script.SDKManager.AdsSDKManager.Utils;
|
||||||
using Script.Utils;
|
using Script.Utils;
|
||||||
using SDK.Utils;
|
using SDK.Utils;
|
||||||
using SDKManager.AdsSDKManager.Constant;
|
using SDKManager.AdsSDKManager.Constant;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
|
||||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
{
|
{
|
||||||
|
|
@ -62,8 +63,8 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
#region 激励广告功能
|
#region 激励广告功能
|
||||||
public void LoadRewarded()
|
public void LoadRewarded()
|
||||||
{
|
{
|
||||||
_admobRewardedAdManager.Destroy();
|
|
||||||
_admobRewardedAdManager = new AdmobRewardedAdManager();
|
_admobRewardedAdManager = new AdmobRewardedAdManager();
|
||||||
|
_admobRewardedAdManager.Destroy();
|
||||||
_admobRewardedAdManager.InitializeAdUnits(
|
_admobRewardedAdManager.InitializeAdUnits(
|
||||||
_rewardedAdUnits,
|
_rewardedAdUnits,
|
||||||
OnRewardedAdLoaded,
|
OnRewardedAdLoaded,
|
||||||
|
|
@ -114,6 +115,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
|
|
||||||
_rvCloseCallback?.Invoke(true);
|
_rvCloseCallback?.Invoke(true);
|
||||||
_rvCloseCallback = null;
|
_rvCloseCallback = null;
|
||||||
|
_admobRewardedAdManager.Destroy();
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,6 +123,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
{
|
{
|
||||||
_rvShowFailedCallback?.Invoke();
|
_rvShowFailedCallback?.Invoke();
|
||||||
_rvShowFailedCallback = null;
|
_rvShowFailedCallback = null;
|
||||||
|
_admobRewardedAdManager.Destroy();
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,8 +142,8 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
#region 插页广告功能
|
#region 插页广告功能
|
||||||
public void LoadInterstitial()
|
public void LoadInterstitial()
|
||||||
{
|
{
|
||||||
_admobInterstitialAdManager.Destroy();
|
|
||||||
_admobInterstitialAdManager = new AdmobInterstitialAdManager();
|
_admobInterstitialAdManager = new AdmobInterstitialAdManager();
|
||||||
|
_admobInterstitialAdManager.Destroy();
|
||||||
_admobInterstitialAdManager.InitializeAdUnits(
|
_admobInterstitialAdManager.InitializeAdUnits(
|
||||||
_interstitialAdUnits,
|
_interstitialAdUnits,
|
||||||
OnInterstitialAdLoaded,
|
OnInterstitialAdLoaded,
|
||||||
|
|
@ -198,6 +201,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
{
|
{
|
||||||
_ivCloseCallback?.Invoke();
|
_ivCloseCallback?.Invoke();
|
||||||
_ivCloseCallback = null;
|
_ivCloseCallback = null;
|
||||||
|
_admobInterstitialAdManager.Destroy();
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,6 +209,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
{
|
{
|
||||||
_ivCloseCallback?.Invoke();
|
_ivCloseCallback?.Invoke();
|
||||||
_ivCloseCallback = null;
|
_ivCloseCallback = null;
|
||||||
|
_admobInterstitialAdManager.Destroy();
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -214,8 +219,8 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
#region 开屏广告功能
|
#region 开屏广告功能
|
||||||
public void LoadSplash()
|
public void LoadSplash()
|
||||||
{
|
{
|
||||||
_admobSplashAdManager.Destroy();
|
|
||||||
_admobSplashAdManager = new AdmobSplashAdManager();
|
_admobSplashAdManager = new AdmobSplashAdManager();
|
||||||
|
_admobSplashAdManager.Destroy();
|
||||||
_admobSplashAdManager.InitializeAdUnits(
|
_admobSplashAdManager.InitializeAdUnits(
|
||||||
_splashAdUnits,
|
_splashAdUnits,
|
||||||
OnSplashAdLoaded,
|
OnSplashAdLoaded,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 3a7b10d4700bc4808b22cd6be81314e8
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cc11ff1f480fa4d58969d2154bf532ec
|
||||||
|
|
@ -8,7 +8,6 @@ using Script.SDKManager.AdsSDKManager.BigoAdsManager;
|
||||||
using Script.SDKManager.AdsSDKManager.MaxAdsManager;
|
using Script.SDKManager.AdsSDKManager.MaxAdsManager;
|
||||||
using Script.SDKManager.AdsSDKManager.TpnAdsManager;
|
using Script.SDKManager.AdsSDKManager.TpnAdsManager;
|
||||||
using Script.SDKManager.AdsSDKManager.Utils;
|
using Script.SDKManager.AdsSDKManager.Utils;
|
||||||
using Script.Utils;
|
|
||||||
using SDK.Utils;
|
using SDK.Utils;
|
||||||
using SDKManager.AdsSDKManager.Constant;
|
using SDKManager.AdsSDKManager.Constant;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -28,22 +27,15 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
|
|
||||||
public void InitSDK()
|
public void InitSDK()
|
||||||
{
|
{
|
||||||
// 初始化广告平台状态
|
KwaiAdsManager.Instance.Init();
|
||||||
BidPlatformManager.Instance.InitializePlatformStates(AdConfigParser.GetAdExpireInSec());
|
AdmobAdsManager.Instance.Initialize();
|
||||||
InitializeAdNetworks();
|
BigoAdsManager.Instance.Initialize();
|
||||||
}
|
TpnAdsManager.Instance.Initialize();
|
||||||
|
MaxAdsManager.Instance.Initialize();
|
||||||
private void InitializeAdNetworks()
|
|
||||||
{
|
|
||||||
_adNetworks.Add(AdmobAdsManager.Instance);
|
_adNetworks.Add(AdmobAdsManager.Instance);
|
||||||
_adNetworks.Add(BigoAdsManager.Instance);
|
_adNetworks.Add(BigoAdsManager.Instance);
|
||||||
_adNetworks.Add(TpnAdsManager.Instance);
|
_adNetworks.Add(TpnAdsManager.Instance);
|
||||||
_adNetworks.Add(MaxAdsManager.Instance);
|
_adNetworks.Add(MaxAdsManager.Instance);
|
||||||
|
|
||||||
foreach (var network in _adNetworks)
|
|
||||||
{
|
|
||||||
network.Initialize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRewardAdReady()
|
public bool IsRewardAdReady()
|
||||||
|
|
@ -64,7 +56,6 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
}
|
}
|
||||||
|
|
||||||
PlatformType result = GetBestPlatformType(false);
|
PlatformType result = GetBestPlatformType(false);
|
||||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Rewarded);
|
|
||||||
if (result == PlatformType.Max)
|
if (result == PlatformType.Max)
|
||||||
{
|
{
|
||||||
MaxAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
MaxAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||||
|
|
@ -89,7 +80,6 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
{
|
{
|
||||||
_showFailedCallback?.Invoke();
|
_showFailedCallback?.Invoke();
|
||||||
}
|
}
|
||||||
CheckAndRefreshExpiredBids(AdsType.Rewarded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInterstitialReady()
|
public bool IsInterstitialReady()
|
||||||
|
|
@ -111,7 +101,6 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
}
|
}
|
||||||
|
|
||||||
PlatformType result = GetBestPlatformType(true);
|
PlatformType result = GetBestPlatformType(true);
|
||||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Interstitial);
|
|
||||||
if (result == PlatformType.Max)
|
if (result == PlatformType.Max)
|
||||||
{
|
{
|
||||||
MaxAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
MaxAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||||
|
|
@ -136,8 +125,6 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
{
|
{
|
||||||
_closeCallback?.Invoke();
|
_closeCallback?.Invoke();
|
||||||
}
|
}
|
||||||
// 刷新其他类型广告
|
|
||||||
CheckAndRefreshExpiredBids(AdsType.Interstitial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlatformType GetBestPlatformType(bool isInterstitial)
|
private PlatformType GetBestPlatformType(bool isInterstitial)
|
||||||
|
|
@ -148,8 +135,6 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
||||||
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
||||||
bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(),
|
bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(),
|
||||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
|
||||||
kwaiPrice: 0,
|
|
||||||
toponAdUnitId: TpnAdsManager.Instance.topon_interstitial_units
|
toponAdUnitId: TpnAdsManager.Instance.topon_interstitial_units
|
||||||
);
|
);
|
||||||
return AdsBidResult.GetPlatformType(priceInfo);
|
return AdsBidResult.GetPlatformType(priceInfo);
|
||||||
|
|
@ -160,143 +145,12 @@ public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||||
maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(),
|
maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(),
|
||||||
admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(),
|
admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(),
|
||||||
bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(),
|
bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(),
|
||||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
|
||||||
kwaiPrice: 0,
|
|
||||||
toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units
|
toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units
|
||||||
);
|
);
|
||||||
return AdsBidResult.GetPlatformType(priceInfo);
|
return AdsBidResult.GetPlatformType(priceInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查并刷新过期竞价
|
|
||||||
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
|
||||||
{
|
|
||||||
Dictionary<PlatformType, List<AdsType>> expiredBids = BidPlatformManager.Instance.GetExpiredBids();
|
|
||||||
|
|
||||||
foreach (var kvp in expiredBids)
|
|
||||||
{
|
|
||||||
PlatformType platformName = kvp.Key;
|
|
||||||
foreach (AdsType adType in kvp.Value)
|
|
||||||
{
|
|
||||||
if (_adsType == adType)
|
|
||||||
{
|
|
||||||
LoggerUtils.Debug($"{platformName} 平台 {adType} 广告竞价已过期,重新加载广告");
|
|
||||||
RefreshPlatformAds(platformName, adType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void RefreshPlatformAds(PlatformType platformName, AdsType adType)
|
|
||||||
{
|
|
||||||
switch (platformName)
|
|
||||||
{
|
|
||||||
case PlatformType.Admob:
|
|
||||||
RefreshAdmobAds(adType);
|
|
||||||
break;
|
|
||||||
case PlatformType.Tpn:
|
|
||||||
RefreshTopOnAds(adType);
|
|
||||||
break;
|
|
||||||
case PlatformType.Max:
|
|
||||||
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: 刷新激励广告
|
|
||||||
break;
|
|
||||||
case AdsType.Interstitial:
|
|
||||||
// todo: 刷新插屏广告
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告看完回调
|
/// 广告看完回调
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
{
|
{
|
||||||
_rvCloseCallback?.Invoke(true);
|
_rvCloseCallback?.Invoke(true);
|
||||||
_rvCloseCallback = null;
|
_rvCloseCallback = null;
|
||||||
|
_rewardedAdManager.Destroy();
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +103,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
{
|
{
|
||||||
_rvShowFailedCallback?.Invoke();
|
_rvShowFailedCallback?.Invoke();
|
||||||
_rvShowFailedCallback = null;
|
_rvShowFailedCallback = null;
|
||||||
|
_rewardedAdManager.Destroy();
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +114,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
|
|
||||||
public void LoadRewarded()
|
public void LoadRewarded()
|
||||||
{
|
{
|
||||||
_rewardedAdManager.Destroy();
|
|
||||||
foreach (var adUnitId in _rewardedAdUnits)
|
foreach (var adUnitId in _rewardedAdUnits)
|
||||||
{
|
{
|
||||||
_rewardedAdManager.LoadAd(adUnitId);
|
_rewardedAdManager.LoadAd(adUnitId);
|
||||||
|
|
@ -157,6 +159,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
{
|
{
|
||||||
_ivCloseCallback?.Invoke();
|
_ivCloseCallback?.Invoke();
|
||||||
_ivCloseCallback = null;
|
_ivCloseCallback = null;
|
||||||
|
_interstitialAdManager.Destroy();
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,6 +167,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
{
|
{
|
||||||
_ivCloseCallback?.Invoke();
|
_ivCloseCallback?.Invoke();
|
||||||
_ivCloseCallback = null;
|
_ivCloseCallback = null;
|
||||||
|
_interstitialAdManager.Destroy();
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +179,6 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
|
|
||||||
public void LoadInterstitial()
|
public void LoadInterstitial()
|
||||||
{
|
{
|
||||||
_interstitialAdManager.Destroy();
|
|
||||||
foreach (var adUnitId in _interstitialAdUnits)
|
foreach (var adUnitId in _interstitialAdUnits)
|
||||||
{
|
{
|
||||||
_interstitialAdManager.LoadAd(adUnitId);
|
_interstitialAdManager.LoadAd(adUnitId);
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int GetAdExpireInSec()
|
public static int GetAdExpireInSec()
|
||||||
{
|
{
|
||||||
return _config?.ad_expire_in_sec ?? -1; // 默认值
|
return _config?.ad_expire_in_sec ?? 3000; // 默认值
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,13 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
||||||
public double MaxPrice;
|
public double MaxPrice;
|
||||||
public double AdmobPrice;
|
public double AdmobPrice;
|
||||||
public double BigoPrice;
|
public double BigoPrice;
|
||||||
public double KwaiPrice;
|
|
||||||
public string ToponAdUnitId;
|
public string ToponAdUnitId;
|
||||||
|
|
||||||
public AdPriceInfo(double maxPrice, double admobPrice, double bigoPrice, double kwaiPrice,string toponAdUnitId)
|
public AdPriceInfo(double maxPrice, double admobPrice, double bigoPrice, string toponAdUnitId)
|
||||||
{
|
{
|
||||||
MaxPrice = maxPrice;
|
MaxPrice = maxPrice;
|
||||||
AdmobPrice = admobPrice;
|
AdmobPrice = admobPrice;
|
||||||
BigoPrice = bigoPrice;
|
BigoPrice = bigoPrice;
|
||||||
KwaiPrice = kwaiPrice;
|
|
||||||
ToponAdUnitId = toponAdUnitId;
|
ToponAdUnitId = toponAdUnitId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +27,6 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
||||||
private static object m_maxObj = "m_maxObj";
|
private static object m_maxObj = "m_maxObj";
|
||||||
private static object m_admobObj = "m_admobObj";
|
private static object m_admobObj = "m_admobObj";
|
||||||
private static object m_bigoObj = "m_bigoObj";
|
private static object m_bigoObj = "m_bigoObj";
|
||||||
private static object m_kwaiObj = "m_kwaiObj";
|
|
||||||
public static PlatformType GetPlatformType(AdPriceInfo priceInfo)
|
public static PlatformType GetPlatformType(AdPriceInfo priceInfo)
|
||||||
{
|
{
|
||||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
|
|
@ -40,15 +37,12 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
||||||
AndroidJavaObject admobCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.AdmobPrice * 1000, m_admobObj);
|
AndroidJavaObject admobCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.AdmobPrice * 1000, m_admobObj);
|
||||||
AndroidJavaObject maxCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.MaxPrice * 1000, m_maxObj);
|
AndroidJavaObject maxCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.MaxPrice * 1000, m_maxObj);
|
||||||
AndroidJavaObject bigoCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.BigoPrice * 1000, m_bigoObj);
|
AndroidJavaObject bigoCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.BigoPrice * 1000, m_bigoObj);
|
||||||
AndroidJavaObject kwaiCustomContentInfo = new AndroidJavaObject("com.anythink.core.api.ATCustomContentInfo", priceInfo.KwaiPrice * 1000, m_kwaiObj);
|
|
||||||
|
|
||||||
|
|
||||||
AndroidJavaObject atCustomContentInfoList = new AndroidJavaObject("java.util.ArrayList");
|
AndroidJavaObject atCustomContentInfoList = new AndroidJavaObject("java.util.ArrayList");
|
||||||
atCustomContentInfoList.Call<bool>("add", toponCustomContentInfo);
|
atCustomContentInfoList.Call<bool>("add", toponCustomContentInfo);
|
||||||
atCustomContentInfoList.Call<bool>("add", admobCustomContentInfo);
|
atCustomContentInfoList.Call<bool>("add", admobCustomContentInfo);
|
||||||
atCustomContentInfoList.Call<bool>("add", maxCustomContentInfo);
|
atCustomContentInfoList.Call<bool>("add", maxCustomContentInfo);
|
||||||
atCustomContentInfoList.Call<bool>("add", bigoCustomContentInfo);
|
atCustomContentInfoList.Call<bool>("add", bigoCustomContentInfo);
|
||||||
atCustomContentInfoList.Call<bool>("add", kwaiCustomContentInfo);
|
|
||||||
|
|
||||||
AndroidJavaClass sdkGlobalSetting = new AndroidJavaClass("com.anythink.core.api.ATSDKGlobalSetting");
|
AndroidJavaClass sdkGlobalSetting = new AndroidJavaClass("com.anythink.core.api.ATSDKGlobalSetting");
|
||||||
AndroidJavaObject maxPriceCustomContentInfo = sdkGlobalSetting.CallStatic<AndroidJavaObject>("customContentReviewResult", atCustomContentInfoList);
|
AndroidJavaObject maxPriceCustomContentInfo = sdkGlobalSetting.CallStatic<AndroidJavaObject>("customContentReviewResult", atCustomContentInfoList);
|
||||||
|
|
@ -58,7 +52,7 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
||||||
AndroidJavaObject customContentObject = maxPriceCustomContentInfo.Get<AndroidJavaObject>("customContentObject");
|
AndroidJavaObject customContentObject = maxPriceCustomContentInfo.Get<AndroidJavaObject>("customContentObject");
|
||||||
|
|
||||||
string customContentObjectString = customContentObject != null ? customContentObject.Call<string>("toString") : "null";
|
string customContentObjectString = customContentObject != null ? customContentObject.Call<string>("toString") : "null";
|
||||||
LoggerUtils.Debug("[AdsBidResult] maxPrice: " + priceInfo.MaxPrice * 1000 + " bigoPrice: " + priceInfo.BigoPrice * 1000 + " admobPrice: " + priceInfo.AdmobPrice * 1000 + " kwaiPrice: " + priceInfo.KwaiPrice * 1000 + " toponAdUnitId: " + priceInfo.ToponAdUnitId);
|
LoggerUtils.Debug("[AdsBidResult] maxPrice: " + priceInfo.MaxPrice * 1000 + " bigoPrice: " + priceInfo.BigoPrice * 1000 + " admobPrice: " + priceInfo.AdmobPrice * 1000);
|
||||||
LoggerUtils.Debug("[AdsBidResult] final maxPriceCustomContentInfo: " + customContentString + " double: " + customContentDouble + " object:" + customContentObjectString);
|
LoggerUtils.Debug("[AdsBidResult] final maxPriceCustomContentInfo: " + customContentString + " double: " + customContentDouble + " object:" + customContentObjectString);
|
||||||
if (customContentObjectString.Equals(m_toponObj))
|
if (customContentObjectString.Equals(m_toponObj))
|
||||||
{
|
{
|
||||||
|
|
@ -76,10 +70,6 @@ namespace Script.SDKManager.AdsSDKManager.Utils
|
||||||
{
|
{
|
||||||
return PlatformType.Bigo;
|
return PlatformType.Bigo;
|
||||||
}
|
}
|
||||||
else if (customContentObjectString.Equals(m_kwaiObj))
|
|
||||||
{
|
|
||||||
return PlatformType.Kwai;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return PlatformType.NULL;
|
return PlatformType.NULL;
|
||||||
|
|
|
||||||
|
|
@ -1,142 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Script.Utils;
|
|
||||||
using SDK.Utils;
|
|
||||||
using UnityEngine;
|
|
||||||
using DKManager.AdsSDKManager.Constant;
|
|
||||||
using SDKManager.AdsSDKManager.Constant;
|
|
||||||
|
|
||||||
namespace Script.SDKManager.AdsSDKManager.Utils
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public class AdTypeBidState
|
|
||||||
{
|
|
||||||
public AdsType AdType;
|
|
||||||
public DateTime LastBidSuccessTime;
|
|
||||||
|
|
||||||
public AdTypeBidState(AdsType adType)
|
|
||||||
{
|
|
||||||
AdType = adType;
|
|
||||||
LastBidSuccessTime = DateTime.MinValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsBidExpired(int expireInSec)
|
|
||||||
{
|
|
||||||
// 如果功能关闭,则不视为过期
|
|
||||||
if (expireInSec == -1) return false;
|
|
||||||
|
|
||||||
// 如果从未成功竞价过,则视为过期
|
|
||||||
// if (LastBidSuccessTime == DateTime.MinValue) return true;
|
|
||||||
|
|
||||||
// 检查是否超过过期时间
|
|
||||||
TimeSpan timeSinceLastBid = DateTime.Now - LastBidSuccessTime;
|
|
||||||
return timeSinceLastBid.TotalSeconds > expireInSec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class BidPlatformState
|
|
||||||
{
|
|
||||||
public PlatformType PlatformName;
|
|
||||||
public bool IsEnabled = true;
|
|
||||||
|
|
||||||
// 每种广告类型的竞价状态
|
|
||||||
public Dictionary<AdsType, AdTypeBidState> AdTypeStates = new Dictionary<AdsType, AdTypeBidState>();
|
|
||||||
|
|
||||||
public BidPlatformState(PlatformType platformName)
|
|
||||||
{
|
|
||||||
PlatformName = platformName;
|
|
||||||
|
|
||||||
// 初始化所有广告类型的状态
|
|
||||||
foreach (AdsType adType in Enum.GetValues(typeof(AdsType)))
|
|
||||||
{
|
|
||||||
AdTypeStates.Add(adType, new AdTypeBidState(adType));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 记录特定广告类型的竞价成功
|
|
||||||
public void RecordBidSuccess(AdsType adType)
|
|
||||||
{
|
|
||||||
if (AdTypeStates.TryGetValue(adType, out var state))
|
|
||||||
{
|
|
||||||
state.LastBidSuccessTime = DateTime.Now;
|
|
||||||
Debug.Log($"{PlatformName} 平台 {adType} 广告竞价成功,记录时间: {state.LastBidSuccessTime}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查特定广告类型的竞价是否过期
|
|
||||||
public bool IsBidExpired(AdsType adType, int expireInSec)
|
|
||||||
{
|
|
||||||
if (!IsEnabled || expireInSec == -1) return false;
|
|
||||||
|
|
||||||
if (AdTypeStates.TryGetValue(adType, out var state))
|
|
||||||
{
|
|
||||||
return state.IsBidExpired(expireInSec);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取所有过期的广告类型
|
|
||||||
public List<AdsType> GetExpiredAdTypes(int expireInSec)
|
|
||||||
{
|
|
||||||
List<AdsType> expiredAdTypes = new List<AdsType>();
|
|
||||||
|
|
||||||
if (!IsEnabled || expireInSec == -1) return expiredAdTypes;
|
|
||||||
|
|
||||||
foreach (var kvp in AdTypeStates)
|
|
||||||
{
|
|
||||||
if (kvp.Value.IsBidExpired(expireInSec))
|
|
||||||
{
|
|
||||||
expiredAdTypes.Add(kvp.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return expiredAdTypes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class BidPlatformManager : NormalSingleton<BidPlatformManager>
|
|
||||||
{
|
|
||||||
private Dictionary<PlatformType, BidPlatformState> _platformStates = new Dictionary<PlatformType, BidPlatformState>();
|
|
||||||
private int _bidExpireInSec = -1;
|
|
||||||
|
|
||||||
public void InitializePlatformStates(int expireInSec)
|
|
||||||
{
|
|
||||||
_bidExpireInSec = expireInSec;
|
|
||||||
_platformStates.Clear();
|
|
||||||
_platformStates.Add(PlatformType.Admob, new BidPlatformState(PlatformType.Admob));
|
|
||||||
_platformStates.Add(PlatformType.Tpn, new BidPlatformState(PlatformType.Tpn));
|
|
||||||
_platformStates.Add(PlatformType.Max, new BidPlatformState(PlatformType.Max));
|
|
||||||
_platformStates.Add(PlatformType.Bigo, new BidPlatformState(PlatformType.Bigo));
|
|
||||||
_platformStates.Add(PlatformType.Kwai, new BidPlatformState(PlatformType.Kwai));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 记录平台竞价成功
|
|
||||||
public void RecordBidSuccess(PlatformType platformName, AdsType adType)
|
|
||||||
{
|
|
||||||
if (_platformStates.TryGetValue(platformName, out var state))
|
|
||||||
{
|
|
||||||
state.RecordBidSuccess(adType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 获取所有过期平台
|
|
||||||
public Dictionary<PlatformType, List<AdsType>> GetExpiredBids()
|
|
||||||
{
|
|
||||||
Dictionary<PlatformType, List<AdsType>> expiredBids = new Dictionary<PlatformType, List<AdsType>>();
|
|
||||||
|
|
||||||
if (_bidExpireInSec == -1) return expiredBids;
|
|
||||||
|
|
||||||
foreach (var kvp in _platformStates)
|
|
||||||
{
|
|
||||||
List<AdsType> expiredAdTypes = kvp.Value.GetExpiredAdTypes(_bidExpireInSec);
|
|
||||||
if (expiredAdTypes.Count > 0)
|
|
||||||
{
|
|
||||||
expiredBids.Add(kvp.Key, expiredAdTypes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return expiredBids;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 8b14631fb6b6547ee9890a43a8ecb2a7
|
|
||||||
Loading…
Reference in New Issue