激励视频、插屏竞价
This commit is contained in:
parent
655f507c30
commit
ed21281638
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using SDKManager.AdsSDKManager.Constant;
|
||||||
namespace Script.Common
|
namespace Script.Common
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -17,27 +18,27 @@ namespace Script.Common
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
#region 横幅广告功能
|
#region 横幅广告功能
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载横幅广告
|
/// 加载横幅广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadBanner();
|
void LoadBanner();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查横幅广告是否可用
|
/// 检查横幅广告是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsBannerAvailable();
|
bool IsBannerAvailable();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示横幅广告
|
/// 显示横幅广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void DisplayBanner();
|
void DisplayBanner();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 隐藏横幅广告
|
/// 隐藏横幅广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void HideBanner();
|
void HideBanner();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取横幅广告收益信息
|
/// 获取横幅广告收益信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -51,17 +52,17 @@ namespace Script.Common
|
||||||
/// 加载插页广告
|
/// 加载插页广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadInterstitial();
|
void LoadInterstitial();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查插页广告是否可用
|
/// 检查插页广告是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsInterstitialAvailable();
|
bool IsInterstitialAvailable();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示插页广告
|
/// 显示插页广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void DisplayInterstitial();
|
void DisplayInterstitial(string _adPos, IvType _IvType = IvType.IV1, Action _closeCallback = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取插页广告收益信息
|
/// 获取插页广告收益信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -75,17 +76,17 @@ namespace Script.Common
|
||||||
/// 加载激励广告
|
/// 加载激励广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadRewarded();
|
void LoadRewarded();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查激励广告是否可用
|
/// 检查激励广告是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsRewardedAvailable();
|
bool IsRewardedAvailable();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示激励广告
|
/// 显示激励广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void DisplayRewarded();
|
void DisplayRewarded(string _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取激励广告收益信息
|
/// 获取激励广告收益信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -99,17 +100,17 @@ namespace Script.Common
|
||||||
/// 加载开屏广告
|
/// 加载开屏广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadSplash();
|
void LoadSplash();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查开屏广告是否可用
|
/// 检查开屏广告是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsSplashAvailable();
|
bool IsSplashAvailable();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示开屏广告
|
/// 显示开屏广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void DisplaySplash();
|
void DisplaySplash();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取开屏广告收益信息
|
/// 获取开屏广告收益信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -123,23 +124,23 @@ namespace Script.Common
|
||||||
/// 加载原生广告
|
/// 加载原生广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadNative();
|
void LoadNative();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查原生广告是否可用
|
/// 检查原生广告是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsNativeAvailable();
|
bool IsNativeAvailable();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示原生广告
|
/// 显示原生广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">广告位置和尺寸信息</param>
|
/// <param name="position">广告位置和尺寸信息</param>
|
||||||
void DisplayNative(NativeAdPosition position);
|
void DisplayNative(NativeAdPosition position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除原生广告
|
/// 移除原生广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void RemoveNative();
|
void RemoveNative();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取原生广告收益信息
|
/// 获取原生广告收益信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -158,7 +159,7 @@ namespace Script.Common
|
||||||
/// 回调消息
|
/// 回调消息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Message;
|
public string Message;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指示广告是否准备就绪
|
/// 指示广告是否准备就绪
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -175,21 +176,28 @@ namespace Script.Common
|
||||||
/// X坐标
|
/// X坐标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int X;
|
public int X;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Y坐标
|
/// Y坐标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Y;
|
public int Y;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告宽度
|
/// 广告宽度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Width;
|
public int Width;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 广告高度
|
/// 广告高度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Height;
|
public int Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public struct HandCallbackInfo
|
||||||
|
{
|
||||||
|
public string msg;
|
||||||
|
public bool isReady;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using GoogleMobileAds.Api;
|
using GoogleMobileAds.Api;
|
||||||
using Script.Common;
|
using Script.Common;
|
||||||
|
@ -5,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
|
||||||
{
|
{
|
||||||
|
@ -22,6 +24,12 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
private List<string> _nativeAdUnits;
|
private List<string> _nativeAdUnits;
|
||||||
private List<string> _splashAdUnits;
|
private List<string> _splashAdUnits;
|
||||||
private List<string> _bannerAdUnits;
|
private List<string> _bannerAdUnits;
|
||||||
|
|
||||||
|
private string _rvPos;
|
||||||
|
private string _ivPos;
|
||||||
|
private Action<bool> _rvCloseCallback = null;
|
||||||
|
private Action _ivCloseCallback = null;
|
||||||
|
private Action _rvShowFailedCallback = null;
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,8 +76,11 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
OnRewardedAdClicked
|
OnRewardedAdClicked
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public void DisplayRewarded()
|
public void DisplayRewarded(string adPos, Action<bool> rewardCallback = null, Action showFailedCallback = null)
|
||||||
{
|
{
|
||||||
|
_rvPos = adPos;
|
||||||
|
_rvCloseCallback = rewardCallback;
|
||||||
|
_rvShowFailedCallback = showFailedCallback;
|
||||||
_admobRewardedAdManager.ShowHighestPayingAd();
|
_admobRewardedAdManager.ShowHighestPayingAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +113,18 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
private void OnRewardedAdDismissed(string adUnitId)
|
private void OnRewardedAdDismissed(string adUnitId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
_rvCloseCallback?.Invoke(true);
|
||||||
|
_rvCloseCallback = null;
|
||||||
|
_admobRewardedAdManager.Destroy();
|
||||||
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRewardedAdError(string adUnitId, int errorCode, string errorMsg)
|
private void OnRewardedAdError(string adUnitId, int errorCode, string errorMsg)
|
||||||
{
|
{
|
||||||
|
_rvShowFailedCallback?.Invoke();
|
||||||
|
_rvShowFailedCallback = null;
|
||||||
|
_admobRewardedAdManager.Destroy();
|
||||||
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRewardedAdClicked(string adUnitId)
|
private void OnRewardedAdClicked(string adUnitId)
|
||||||
|
@ -143,8 +160,10 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
return _admobInterstitialAdManager.GetHighestPayingAdRevenue();
|
return _admobInterstitialAdManager.GetHighestPayingAdRevenue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisplayInterstitial()
|
public void DisplayInterstitial(string ivPos, IvType _IvType = IvType.IV1, Action closeCallback = null)
|
||||||
{
|
{
|
||||||
|
_ivPos = ivPos;
|
||||||
|
_ivCloseCallback = closeCallback;
|
||||||
_admobInterstitialAdManager.ShowHighestPayingAd();
|
_admobInterstitialAdManager.ShowHighestPayingAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,12 +199,18 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
|
|
||||||
private void OnInterstitialAdDismissed(string adUnitId)
|
private void OnInterstitialAdDismissed(string adUnitId)
|
||||||
{
|
{
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
|
_admobInterstitialAdManager.Destroy();
|
||||||
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInterstitialAdError(string adUnitId, int errorCode, string errorMsg)
|
private void OnInterstitialAdError(string adUnitId, int errorCode, string errorMsg)
|
||||||
{
|
{
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
|
_admobInterstitialAdManager.Destroy();
|
||||||
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||||
{
|
{
|
||||||
return revenue;
|
return revenue;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理资源
|
// 清理资源
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using DKManager.AdsSDKManager.Constant;
|
||||||
|
using Script.Common;
|
||||||
|
using Script.SDKManager.AdsSDKManager.AdmobAdsManager;
|
||||||
|
using Script.SDKManager.AdsSDKManager.BigoAdsManager;
|
||||||
|
using Script.SDKManager.AdsSDKManager.MaxAdsManager;
|
||||||
|
using Script.SDKManager.AdsSDKManager.TpnAdsManager;
|
||||||
|
using Script.SDKManager.AdsSDKManager.Utils;
|
||||||
|
using SDKManager.AdsSDKManager.Constant;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class AdsSDKManager : MonoBehaviour
|
public class AdsSDKManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static AdsSDKManager instance;
|
public static AdsSDKManager instance;
|
||||||
|
private List<IAdService> _adNetworks = new List<IAdService>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 看完广告的回调
|
/// 看完广告的回调
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -26,16 +36,127 @@ public class AdsSDKManager : MonoBehaviour
|
||||||
private void InitSDK()
|
private void InitSDK()
|
||||||
{
|
{
|
||||||
KwaiAdsManager.Init();
|
KwaiAdsManager.Init();
|
||||||
|
AdmobAdsManager.Instance.Initialize();
|
||||||
|
BigoAdsManager.Instance.Initialize();
|
||||||
|
TpnAdsManager.Instance.Initialize();
|
||||||
|
MaxAdsManager.Instance.Initialize();
|
||||||
|
_adNetworks.Add(AdmobAdsManager.Instance);
|
||||||
|
_adNetworks.Add(BigoAdsManager.Instance);
|
||||||
|
_adNetworks.Add(TpnAdsManager.Instance);
|
||||||
|
_adNetworks.Add(MaxAdsManager.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsRewardAdReady()
|
||||||
|
{
|
||||||
|
return _adNetworks.Any(network => network.IsRewardedAvailable());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 展示激励广告
|
/// 展示激励广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="callback"></param>
|
/// <param name="callback"></param>
|
||||||
private void ShowRewardAd(Action<double> callback)
|
public void ShowRewardAd(string _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null)
|
||||||
{
|
{
|
||||||
AdRewardCallback = callback;
|
if (!IsRewardAdReady())
|
||||||
|
{
|
||||||
|
_showFailedCallback?.Invoke();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlatformType result = GetBestPlatformType(false);
|
||||||
|
if (result == PlatformType.Max)
|
||||||
|
{
|
||||||
|
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.Tpn)
|
||||||
|
{
|
||||||
|
TpnAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||||
|
}
|
||||||
|
else if (result == PlatformType.Kwai)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_showFailedCallback?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsInterstitialReady()
|
||||||
|
{
|
||||||
|
return _adNetworks.Any(network => network.IsInterstitialAvailable());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 展示激励广告
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="callback"></param>
|
||||||
|
public void ShowInterstitialAd(string _adPos, IvType _IvType = IvType.IV1, Action _closeCallback = null)
|
||||||
|
{
|
||||||
|
if (!IsRewardAdReady())
|
||||||
|
{
|
||||||
|
_closeCallback?.Invoke();
|
||||||
|
_closeCallback = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlatformType result = GetBestPlatformType(true);
|
||||||
|
if (result == PlatformType.Max)
|
||||||
|
{
|
||||||
|
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.Tpn)
|
||||||
|
{
|
||||||
|
TpnAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||||
|
}
|
||||||
|
else if (result == PlatformType.Kwai)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_closeCallback?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlatformType GetBestPlatformType(bool isInterstitial)
|
||||||
|
{
|
||||||
|
if (isInterstitial)
|
||||||
|
{
|
||||||
|
AdPriceInfo priceInfo = new AdPriceInfo(
|
||||||
|
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
||||||
|
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
||||||
|
bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(),
|
||||||
|
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(),
|
||||||
|
toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units
|
||||||
|
);
|
||||||
|
return AdsBidResult.GetPlatformType(priceInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -21,8 +21,12 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
private List<string> _interstitialAdUnits;
|
private List<string> _interstitialAdUnits;
|
||||||
private List<string> _rewardedAdUnits;
|
private List<string> _rewardedAdUnits;
|
||||||
public string bigo_app_id;
|
public string bigo_app_id;
|
||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
private string _rvPos;
|
||||||
|
private string _IvPos;
|
||||||
|
private Action<bool> _rvCloseCallback = null;
|
||||||
|
private Action _ivCloseCallback = null;
|
||||||
|
private Action _rvShowFailedCallback = null;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
@ -34,7 +38,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Bigo] sdk init success");
|
LoggerUtils.Debug($"[Bigo] sdk init success");
|
||||||
if (_rewardedAdUnits.Count > 0)
|
if (_rewardedAdUnits.Count > 0)
|
||||||
{
|
{
|
||||||
_rewardedAdManager = new BigoRewardedAdManager();
|
_rewardedAdManager = new BigoRewardedAdManager();
|
||||||
_rewardedAdManager.InitializeAdUnits(
|
_rewardedAdManager.InitializeAdUnits(
|
||||||
_rewardedAdUnits,
|
_rewardedAdUnits,
|
||||||
|
@ -48,7 +52,7 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_interstitialAdUnits.Count > 0)
|
if (_interstitialAdUnits.Count > 0)
|
||||||
{
|
{
|
||||||
_interstitialAdManager = new BigoInterstitialAdManager();
|
_interstitialAdManager = new BigoInterstitialAdManager();
|
||||||
_interstitialAdManager.InitializeAdUnits(
|
_interstitialAdManager.InitializeAdUnits(
|
||||||
_interstitialAdUnits,
|
_interstitialAdUnits,
|
||||||
|
@ -88,13 +92,19 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
}
|
}
|
||||||
private void OnRewardedAdDismissed(string adUnitId)
|
private void OnRewardedAdDismissed(string adUnitId)
|
||||||
{
|
{
|
||||||
|
_rvCloseCallback?.Invoke(true);
|
||||||
|
_rvCloseCallback = null;
|
||||||
_rewardedAdManager.Destroy();
|
_rewardedAdManager.Destroy();
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRewardedAdError(string adUnitId, int code, string msg)
|
private void OnRewardedAdError(string adUnitId, int code, string msg)
|
||||||
{
|
{
|
||||||
|
_rvShowFailedCallback?.Invoke();
|
||||||
|
_rvShowFailedCallback = null;
|
||||||
|
_rewardedAdManager.Destroy();
|
||||||
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRewardedAdClicked()
|
private void OnRewardedAdClicked()
|
||||||
|
@ -117,8 +127,11 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
return _rewardedAdManager.GetAvailableAdUnits().Count > 0;
|
return _rewardedAdManager.GetAvailableAdUnits().Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisplayRewarded()
|
public void DisplayRewarded(string adPos, Action<bool> rewardCallback = null, Action showFailedCallback = null)
|
||||||
{
|
{
|
||||||
|
_rvPos = adPos;
|
||||||
|
_rvCloseCallback = rewardCallback;
|
||||||
|
_rvShowFailedCallback = showFailedCallback;
|
||||||
_rewardedAdManager.ShowHighestPayingAd();
|
_rewardedAdManager.ShowHighestPayingAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,12 +157,18 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
}
|
}
|
||||||
private void OnInterstitialAdDismissed(string adUnitId)
|
private void OnInterstitialAdDismissed(string adUnitId)
|
||||||
{
|
{
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
_interstitialAdManager.Destroy();
|
_interstitialAdManager.Destroy();
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInterstitialAdError(string adUnitId, int code, string msg)
|
private void OnInterstitialAdError(string adUnitId, int code, string msg)
|
||||||
{
|
{
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
|
_interstitialAdManager.Destroy();
|
||||||
|
LoadInterstitial();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +191,10 @@ namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||||
return _interstitialAdManager.GetAvailableAdUnits().Count > 0;
|
return _interstitialAdManager.GetAvailableAdUnits().Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisplayInterstitial()
|
public void DisplayInterstitial(string ivPos, IvType _IvType = IvType.IV1, Action closeCallback = null)
|
||||||
{
|
{
|
||||||
|
_IvPos = ivPos;
|
||||||
|
_ivCloseCallback = closeCallback;
|
||||||
_interstitialAdManager.ShowHighestPayingAd();
|
_interstitialAdManager.ShowHighestPayingAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace SDKManager.AdsSDKManager.Constant
|
||||||
|
{
|
||||||
|
public enum IvType
|
||||||
|
{
|
||||||
|
NULL = -1,
|
||||||
|
IV1 = 0,
|
||||||
|
IV2 = 1,
|
||||||
|
IV3 = 2,
|
||||||
|
IV4 = 3,
|
||||||
|
IV5 = 4,
|
||||||
|
IV6 = 5,
|
||||||
|
IV7 = 6,
|
||||||
|
IV8 = 7,
|
||||||
|
IVAuto = 999,
|
||||||
|
MAX
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d0e4c55fdbb5b436f944b08b198aca51
|
|
@ -10,7 +10,7 @@ namespace DKManager.AdsSDKManager.Constant
|
||||||
Tpn,
|
Tpn,
|
||||||
Admob,
|
Admob,
|
||||||
Bigo,
|
Bigo,
|
||||||
KWai,
|
Kwai,
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,11 @@ namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||||
private int _interRetryAttempt;
|
private int _interRetryAttempt;
|
||||||
private float _rvStartLoadTime = 0;
|
private float _rvStartLoadTime = 0;
|
||||||
private float _ivStartLoadTime = 0;
|
private float _ivStartLoadTime = 0;
|
||||||
|
private string _rvPos;
|
||||||
|
private string _ivPos;
|
||||||
|
private Action<bool> _rvCloseCallback = null;
|
||||||
|
private Action _ivCloseCallback = null;
|
||||||
|
private Action _rvShowFailedCallback = null;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
@ -65,8 +70,11 @@ namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||||
{
|
{
|
||||||
MaxSdk.LoadRewardedAd(max_rewarded_units);
|
MaxSdk.LoadRewardedAd(max_rewarded_units);
|
||||||
}
|
}
|
||||||
public void DisplayRewarded()
|
public void DisplayRewarded(string adPos, Action<bool> rewardCallback = null, Action showFailedCallback = null)
|
||||||
{
|
{
|
||||||
|
_rvPos = adPos;
|
||||||
|
_rvCloseCallback = rewardCallback;
|
||||||
|
_rvShowFailedCallback = showFailedCallback;
|
||||||
MaxSdk.ShowRewardedAd(max_rewarded_units);
|
MaxSdk.ShowRewardedAd(max_rewarded_units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +128,15 @@ namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||||
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
|
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug("[Max] OnRewardedAdFailedToDisplayEvent :" + errorInfo.Message + " " + errorInfo.Code + " " + errorInfo.MediatedNetworkErrorMessage + " " + errorInfo.MediatedNetworkErrorCode);
|
LoggerUtils.Debug("[Max] OnRewardedAdFailedToDisplayEvent :" + errorInfo.Message + " " + errorInfo.Code + " " + errorInfo.MediatedNetworkErrorMessage + " " + errorInfo.MediatedNetworkErrorCode);
|
||||||
|
_rvShowFailedCallback?.Invoke();
|
||||||
|
_rvShowFailedCallback = null;
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
private void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
|
_rvCloseCallback?.Invoke(true);
|
||||||
|
_rvCloseCallback = null;
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
LoggerUtils.Debug("[Max] OnRewardedAdHiddenEvent");
|
LoggerUtils.Debug("[Max] OnRewardedAdHiddenEvent");
|
||||||
}
|
}
|
||||||
|
@ -159,8 +171,10 @@ namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisplayInterstitial()
|
public void DisplayInterstitial(string ivPos, IvType _IvType = IvType.IV1, Action closeCallback = null)
|
||||||
{
|
{
|
||||||
|
_ivPos = ivPos;
|
||||||
|
_ivCloseCallback = closeCallback;
|
||||||
MaxSdk.ShowInterstitial(max_interstitial_units);
|
MaxSdk.ShowInterstitial(max_interstitial_units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +202,8 @@ namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||||
private void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,MaxSdkBase.AdInfo arg3)
|
private void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,MaxSdkBase.AdInfo arg3)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug("[Max] OnInterstitialAdFailedToDisplayEvent :" + errorInfo.Message + " " + errorInfo.Code + " " + errorInfo.MediatedNetworkErrorMessage + " " + errorInfo.MediatedNetworkErrorCode);
|
LoggerUtils.Debug("[Max] OnInterstitialAdFailedToDisplayEvent :" + errorInfo.Message + " " + errorInfo.Code + " " + errorInfo.MediatedNetworkErrorMessage + " " + errorInfo.MediatedNetworkErrorCode);
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +216,8 @@ namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||||
private void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo info)
|
private void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo info)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Max] OnInterstitialHiddenEvent");
|
LoggerUtils.Debug($"[Max] OnInterstitialHiddenEvent");
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -21,6 +22,11 @@ namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||||
public string topon_app_key;
|
public string topon_app_key;
|
||||||
public string topon_interstitial_units;
|
public string topon_interstitial_units;
|
||||||
public string topon_rewarded_units;
|
public string topon_rewarded_units;
|
||||||
|
private string _rvPos;
|
||||||
|
private string _ivPos;
|
||||||
|
private Action<bool> _rvCloseCallback = null;
|
||||||
|
private Action _ivCloseCallback = null;
|
||||||
|
private Action _rvShowFailedCallback = null;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
@ -28,7 +34,7 @@ namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||||
topon_app_key = AdConfigParser.GetTopOnAppKey();
|
topon_app_key = AdConfigParser.GetTopOnAppKey();
|
||||||
topon_interstitial_units = AdConfigParser.GetTopOnAdUnits(AdsType.Interstitial).ToArray()[0];
|
topon_interstitial_units = AdConfigParser.GetTopOnAdUnits(AdsType.Interstitial).ToArray()[0];
|
||||||
topon_rewarded_units = AdConfigParser.GetTopOnAdUnits(AdsType.Rewarded).ToArray()[0];
|
topon_rewarded_units = AdConfigParser.GetTopOnAdUnits(AdsType.Rewarded).ToArray()[0];
|
||||||
LoggerUtils.Debug("[Tpn] 初始化 Tpn 广告 SDK appid:"+topon_app_id+" appkey:"+topon_app_key+" ivId:"+topon_interstitial_units+" rvId:"+topon_rewarded_units );
|
LoggerUtils.Debug("[Tpn] 初始化 Tpn 广告 SDK appid:" + topon_app_id + " appkey:" + topon_app_key + " ivId:" + topon_interstitial_units + " rvId:" + topon_rewarded_units);
|
||||||
if (!string.IsNullOrEmpty(topon_app_id) && !string.IsNullOrEmpty(topon_app_key))
|
if (!string.IsNullOrEmpty(topon_app_id) && !string.IsNullOrEmpty(topon_app_key))
|
||||||
{
|
{
|
||||||
ATSDKAPI.initSDK(topon_app_id, topon_app_key);
|
ATSDKAPI.initSDK(topon_app_id, topon_app_key);
|
||||||
|
@ -53,8 +59,11 @@ namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||||
|
|
||||||
}
|
}
|
||||||
public void LoadRewarded() {}
|
public void LoadRewarded() {}
|
||||||
public void DisplayRewarded()
|
public void DisplayRewarded(string adPos, Action<bool> rewardCallback = null, Action showFailedCallback = null)
|
||||||
{
|
{
|
||||||
|
_rvPos = adPos;
|
||||||
|
_rvCloseCallback = rewardCallback;
|
||||||
|
_rvShowFailedCallback = showFailedCallback;
|
||||||
ATRewardedAutoVideo.Instance.showAutoAd(topon_rewarded_units);
|
ATRewardedAutoVideo.Instance.showAutoAd(topon_rewarded_units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +92,10 @@ namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||||
public void LoadInterstitial(){}
|
public void LoadInterstitial(){}
|
||||||
public double GetInterstitialRevenue(){return 0;}
|
public double GetInterstitialRevenue(){return 0;}
|
||||||
|
|
||||||
public void DisplayInterstitial()
|
public void DisplayInterstitial(string ivPos, IvType _IvType = IvType.IV1, Action closeCallback = null)
|
||||||
{
|
{
|
||||||
|
_ivPos = ivPos;
|
||||||
|
_ivCloseCallback = closeCallback;
|
||||||
ATInterstitialAutoAd.Instance.showAutoAd(topon_interstitial_units);
|
ATInterstitialAutoAd.Instance.showAutoAd(topon_interstitial_units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,11 +149,13 @@ namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||||
|
|
||||||
if (erg.placementId.Equals(topon_rewarded_units))
|
if (erg.placementId.Equals(topon_rewarded_units))
|
||||||
{
|
{
|
||||||
|
_rvShowFailedCallback?.Invoke();
|
||||||
|
_rvShowFailedCallback = null;
|
||||||
}
|
}
|
||||||
else if (erg.placementId.Equals(topon_interstitial_units))
|
else if (erg.placementId.Equals(topon_interstitial_units))
|
||||||
{
|
{
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
}
|
}
|
||||||
}, "");
|
}, "");
|
||||||
}
|
}
|
||||||
|
@ -155,11 +168,13 @@ namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||||
{
|
{
|
||||||
if (erg.placementId.Equals(topon_rewarded_units))
|
if (erg.placementId.Equals(topon_rewarded_units))
|
||||||
{
|
{
|
||||||
|
_rvCloseCallback?.Invoke(true);
|
||||||
|
_rvCloseCallback = null;
|
||||||
}
|
}
|
||||||
else if (erg.placementId.Equals(topon_interstitial_units))
|
else if (erg.placementId.Equals(topon_interstitial_units))
|
||||||
{
|
{
|
||||||
|
_ivCloseCallback?.Invoke();
|
||||||
|
_ivCloseCallback = null;
|
||||||
}
|
}
|
||||||
}, "");
|
}, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ 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";
|
||||||
public static PlatformType GetCustomContentInfo(AdPriceInfo priceInfo)
|
public static PlatformType GetPlatformType(AdPriceInfo priceInfo)
|
||||||
{
|
{
|
||||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||||||
|
|
Loading…
Reference in New Issue