Merge branch 'main' of http://v4.9ms.co:7777/yufeng/SDK_UnityMoney
This commit is contained in:
commit
2fa583de83
|
@ -233,10 +233,34 @@ namespace WZ
|
||||||
// and anchored to the bottom of the screne.
|
// and anchored to the bottom of the screne.
|
||||||
ad.RenderTemplate(style, new AdSize(position.Width, position.Height), position.X, position.Y);
|
ad.RenderTemplate(style, new AdSize(position.Width, position.Height), position.X, position.Y);
|
||||||
|
|
||||||
|
|
||||||
|
var showNativePosition = showingNativeAds.GetValueOrDefault(adUnitId, null);
|
||||||
|
|
||||||
|
|
||||||
|
var lastAdResponseId = lastAd?.GetResponseInfo()?.GetResponseId();
|
||||||
|
var lastShowAdResponseId = lastShowAd?.GetResponseInfo()?.GetResponseId();
|
||||||
|
var lastShowAdResponseId2 = showNativePosition?.NativeOverlayAd?.GetResponseInfo()?.GetResponseId();
|
||||||
|
|
||||||
|
var showAdResponseId = ad.GetResponseInfo()?.GetResponseId();
|
||||||
|
|
||||||
|
LoggerUtils.Debug(
|
||||||
|
$"[Admob] Native ad ShowAd [showingNativeAds] {adUnitId} , showAdResponseId = {showAdResponseId} , lastAdResponseId = {lastAdResponseId} , lastShowAdResponseId = {lastShowAdResponseId} , lastShowAdResponseId2 = {lastShowAdResponseId2}");
|
||||||
|
|
||||||
showingNativeAds[adUnitId] = new ShowNativePosition(ad, position);
|
showingNativeAds[adUnitId] = new ShowNativePosition(ad, position);
|
||||||
ad.Show();
|
ad.Show();
|
||||||
lastAd?.Hide();
|
|
||||||
lastShowAd?.Hide();
|
try
|
||||||
|
{
|
||||||
|
lastAd?.Hide();
|
||||||
|
lastShowAd?.Hide();
|
||||||
|
showNativePosition?.NativeOverlayAd?.Hide();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LoggerUtils.Error($"[Admob] Native ad Hide fail {adUnitId} , e : {e.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TimingRefresh(adUnitId);
|
TimingRefresh(adUnitId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,8 +389,9 @@ namespace WZ
|
||||||
{
|
{
|
||||||
foreach (var key in showingNativeAds.Keys.ToList())
|
foreach (var key in showingNativeAds.Keys.ToList())
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Admob] Native ad removing NativeAd {adUnitId}");
|
var ad = showingNativeAds[key].NativeOverlayAd;
|
||||||
showingNativeAds[key].NativeOverlayAd.Hide();
|
LoggerUtils.Debug($"[Admob] Native ad removing [showingNativeAds] {adUnitId} , ad {ad.GetResponseInfo()?.GetResponseId()}");
|
||||||
|
ad.Hide();
|
||||||
// 从字典中删除元素
|
// 从字典中删除元素
|
||||||
showingNativeAds.Remove(key);
|
showingNativeAds.Remove(key);
|
||||||
LoadAd(key);
|
LoadAd(key);
|
||||||
|
@ -377,8 +402,9 @@ namespace WZ
|
||||||
|
|
||||||
if (showingNativeAds.TryGetValue(adUnitId, out var tempAd))
|
if (showingNativeAds.TryGetValue(adUnitId, out var tempAd))
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Admob] Native ad removing NativeAd {adUnitId}");
|
var ad = tempAd.NativeOverlayAd;
|
||||||
tempAd.NativeOverlayAd.Hide();
|
LoggerUtils.Debug($"[Admob] Native ad removing [showingNativeAds] {adUnitId} , ad {ad.GetResponseInfo()?.GetResponseId()}");
|
||||||
|
ad.Hide();
|
||||||
showingNativeAds.Remove(adUnitId);
|
showingNativeAds.Remove(adUnitId);
|
||||||
LoadAd(adUnitId);
|
LoadAd(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,7 @@ namespace WZ
|
||||||
|
|
||||||
#region IvRules
|
#region IvRules
|
||||||
|
|
||||||
public bool IvRulesShow(IvType ivadType)
|
public bool IvRulesShow(IvType ivadType, bool isShow = true)
|
||||||
{
|
{
|
||||||
//1.获取远程配置
|
//1.获取远程配置
|
||||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
||||||
|
@ -367,7 +367,10 @@ namespace WZ
|
||||||
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 前N次不展示插屏, 本地次数是{currentSkipLevel + 1}, 远程参数是{skipLevel}");
|
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 前N次不展示插屏, 本地次数是{currentSkipLevel + 1}, 远程参数是{skipLevel}");
|
||||||
if (currentSkipLevel < skipLevel)
|
if (currentSkipLevel < skipLevel)
|
||||||
{
|
{
|
||||||
PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", currentSkipLevel + 1);
|
if (isShow)
|
||||||
|
{
|
||||||
|
PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", currentSkipLevel + 1);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//5.判断overLevel(每跳过几次触发) 第一次会展示 之后每展示一次间隔+1
|
//5.判断overLevel(每跳过几次触发) 第一次会展示 之后每展示一次间隔+1
|
||||||
|
@ -376,14 +379,18 @@ namespace WZ
|
||||||
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 当前间隔次数: 本地次数是{currentOverLevel + 1}, 远程参数是{overLevel}");
|
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 当前间隔次数: 本地次数是{currentOverLevel + 1}, 远程参数是{overLevel}");
|
||||||
if (currentOverLevel != 0)
|
if (currentOverLevel != 0)
|
||||||
{
|
{
|
||||||
if (currentOverLevel >= overLevel)
|
if (isShow)
|
||||||
{
|
{
|
||||||
IvRulesConst.OverLevels[ivadType.ToString()] = 0;
|
if (currentOverLevel >= overLevel)
|
||||||
}
|
{
|
||||||
else
|
IvRulesConst.OverLevels[ivadType.ToString()] = 0;
|
||||||
{
|
}
|
||||||
IvRulesConst.OverLevels[ivadType.ToString()] += 1;
|
else
|
||||||
|
{
|
||||||
|
IvRulesConst.OverLevels[ivadType.ToString()] += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,9 +230,13 @@ namespace WZ
|
||||||
|
|
||||||
private Parameter GetParameter(string key, object value)
|
private Parameter GetParameter(string key, object value)
|
||||||
{
|
{
|
||||||
Type type = value.GetType();
|
|
||||||
|
|
||||||
// 根据类型进行转换
|
// 根据类型进行转换
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
return new Parameter(key, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
Type type = value.GetType();
|
||||||
if (type == typeof(string))
|
if (type == typeof(string))
|
||||||
{
|
{
|
||||||
return new Parameter(key, value as string);
|
return new Parameter(key, value as string);
|
||||||
|
|
|
@ -167,6 +167,16 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
return AdsSDKManager.Instance.IsInterstitialReady();
|
return AdsSDKManager.Instance.IsInterstitialReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否能展示插屏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ivType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool CanShowInterstitialAd(IvType ivType)
|
||||||
|
{
|
||||||
|
return AdsSDKManager.Instance.IvRulesShow(ivType, false);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 展示插屏广告
|
/// 展示插屏广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -258,7 +268,14 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowFullNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rectTransform"></param>
|
||||||
|
/// <param name="pCom"></param>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <param name="nativeTemplateStyle"></param>
|
||||||
|
public void ShowFullNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||||||
{
|
{
|
||||||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||||||
if (!IsNativeFullReady())
|
if (!IsNativeFullReady())
|
||||||
|
@ -268,11 +285,17 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
}
|
}
|
||||||
|
|
||||||
var adUnitId = StaticValue.AdmobFullNativeId;
|
var adUnitId = StaticValue.AdmobFullNativeId;
|
||||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
|
||||||
|
if (nativeTemplateStyle == null)
|
||||||
{
|
{
|
||||||
TemplateId = NativeTemplateId.Medium,
|
nativeTemplateStyle = new NativeTemplateStyle
|
||||||
MainBackgroundColor = Color.white
|
{
|
||||||
}, rectTransform, pCom);
|
TemplateId = NativeTemplateId.Medium,
|
||||||
|
MainBackgroundColor = Color.white
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||||||
|
|
||||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +327,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
public void ShowNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||||||
{
|
{
|
||||||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||||||
if (!IsNativeReady())
|
if (!IsNativeReady())
|
||||||
|
@ -312,13 +335,20 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nativeTemplateStyle == null)
|
||||||
|
{
|
||||||
|
nativeTemplateStyle = new NativeTemplateStyle
|
||||||
|
{
|
||||||
|
//除了中型Native,其他的都是Small
|
||||||
|
TemplateId = NativeTemplateId.Small,
|
||||||
|
//背景颜色
|
||||||
|
MainBackgroundColor = Color.white
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var adUnitId = StaticValue.AdmobNativeId;
|
var adUnitId = StaticValue.AdmobNativeId;
|
||||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||||||
{
|
|
||||||
TemplateId = NativeTemplateId.Small,
|
|
||||||
MainBackgroundColor = Color.white
|
|
||||||
}, rectTransform, pCom);
|
|
||||||
|
|
||||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||||
}
|
}
|
||||||
|
@ -335,7 +365,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowSmallNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
public void ShowSmallNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||||||
{
|
{
|
||||||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||||||
if (!IsSmallNativeReady())
|
if (!IsSmallNativeReady())
|
||||||
|
@ -343,13 +373,18 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nativeTemplateStyle == null)
|
||||||
|
{
|
||||||
|
nativeTemplateStyle = new NativeTemplateStyle
|
||||||
|
{
|
||||||
|
TemplateId = NativeTemplateId.Small,
|
||||||
|
MainBackgroundColor = Color.white
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||||||
{
|
|
||||||
TemplateId = NativeTemplateId.Small,
|
|
||||||
MainBackgroundColor = Color.white
|
|
||||||
}, rectTransform, pCom);
|
|
||||||
|
|
||||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||||
}
|
}
|
||||||
|
@ -366,7 +401,7 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowMinddleNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
public void ShowMinddleNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||||||
{
|
{
|
||||||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||||||
if (!IsMinddleNativeReady())
|
if (!IsMinddleNativeReady())
|
||||||
|
@ -374,13 +409,18 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||||||
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nativeTemplateStyle == null)
|
||||||
|
{
|
||||||
|
nativeTemplateStyle = new NativeTemplateStyle
|
||||||
|
{
|
||||||
|
TemplateId = NativeTemplateId.Small,
|
||||||
|
MainBackgroundColor = Color.white
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||||||
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||||||
{
|
|
||||||
TemplateId = NativeTemplateId.Small,
|
|
||||||
MainBackgroundColor = Color.white
|
|
||||||
}, rectTransform, pCom);
|
|
||||||
|
|
||||||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue