native
This commit is contained in:
parent
3286e0e33e
commit
8b51352e5a
|
|
@ -13,7 +13,7 @@ OcclusionCullingSettings:
|
||||||
--- !u!104 &2
|
--- !u!104 &2
|
||||||
RenderSettings:
|
RenderSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 10
|
serializedVersion: 9
|
||||||
m_Fog: 0
|
m_Fog: 0
|
||||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
m_FogMode: 3
|
m_FogMode: 3
|
||||||
|
|
@ -38,12 +38,12 @@ RenderSettings:
|
||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 0}
|
m_Sun: {fileID: 0}
|
||||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 12
|
serializedVersion: 12
|
||||||
|
m_GIWorkflowMode: 1
|
||||||
m_GISettings:
|
m_GISettings:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_BounceScale: 1
|
m_BounceScale: 1
|
||||||
|
|
@ -66,6 +66,9 @@ LightmapSettings:
|
||||||
m_LightmapParameters: {fileID: 0}
|
m_LightmapParameters: {fileID: 0}
|
||||||
m_LightmapsBakeMode: 1
|
m_LightmapsBakeMode: 1
|
||||||
m_TextureCompression: 1
|
m_TextureCompression: 1
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_FinalGatherRayCount: 256
|
||||||
m_ReflectionCompression: 2
|
m_ReflectionCompression: 2
|
||||||
m_MixedBakeMode: 2
|
m_MixedBakeMode: 2
|
||||||
m_BakeBackend: 0
|
m_BakeBackend: 0
|
||||||
|
|
@ -645,6 +648,8 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 231270963}
|
- {fileID: 231270963}
|
||||||
- {fileID: 2018301549}
|
- {fileID: 2018301549}
|
||||||
|
- {fileID: 1979832641}
|
||||||
|
- {fileID: 1439137377}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
|
@ -664,6 +669,81 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 8a53fe0e9eb9de04e86fd13d32d89b42, type: 3}
|
m_Script: {fileID: 11500000, guid: 8a53fe0e9eb9de04e86fd13d32d89b42, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &1439137376
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1439137377}
|
||||||
|
- component: {fileID: 1439137379}
|
||||||
|
- component: {fileID: 1439137378}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: NativeAd-medium
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1439137377
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1439137376}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1332931146}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -334.5}
|
||||||
|
m_SizeDelta: {x: 0, y: 669}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &1439137378
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1439137376}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 0.98039216, g: 0.99607843, b: 0.45882353, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 0}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1439137379
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1439137376}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1715967757
|
--- !u!1 &1715967757
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -743,6 +823,81 @@ CanvasRenderer:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1715967757}
|
m_GameObject: {fileID: 1715967757}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &1979832640
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1979832641}
|
||||||
|
- component: {fileID: 1979832643}
|
||||||
|
- component: {fileID: 1979832642}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: NativeAd-small
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1979832641
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1979832640}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1332931146}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 0}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 134.5}
|
||||||
|
m_SizeDelta: {x: 0, y: 269}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &1979832642
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1979832640}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 0.98039216, g: 0.99607843, b: 0.45882353, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 0}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1979832643
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1979832640}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &2018301548
|
--- !u!1 &2018301548
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using GoogleMobileAds.Api;
|
using GoogleMobileAds.Api;
|
||||||
using UnityEditor.Media;
|
using UnityEngine;
|
||||||
|
|
||||||
|
// using UnityEditor.Media;
|
||||||
|
|
||||||
namespace WZ
|
namespace WZ
|
||||||
{
|
{
|
||||||
|
|
@ -134,23 +136,23 @@ namespace WZ
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查原生广告是否可用
|
/// 检查原生广告是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsNativeAvailable();
|
bool IsNativeAvailable(string adUnitId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示原生广告
|
/// 显示原生广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">广告位置和尺寸信息</param>
|
/// <param name="position">广告位置和尺寸信息</param>
|
||||||
void DisplayNative(NativeAdPosition position);
|
void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除原生广告
|
/// 移除原生广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void RemoveNative();
|
void RemoveNative(string adUnitId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取原生广告收益信息
|
/// 获取原生广告收益信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
double GetNativeRevenue();
|
double GetNativeRevenue(string adUnitId);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
@ -199,6 +201,26 @@ namespace WZ
|
||||||
public int Height;
|
public int Height;
|
||||||
|
|
||||||
public NativeTemplateStyle NativeTemplateStyle;
|
public NativeTemplateStyle NativeTemplateStyle;
|
||||||
|
|
||||||
|
|
||||||
|
public static NativeAdPosition Create(NativeTemplateStyle nativeTemplateStyle,RectTransform pRect, Camera pCam = null)
|
||||||
|
{
|
||||||
|
var tWorldCorners = new Vector3[4];
|
||||||
|
pRect.GetWorldCorners(tWorldCorners);
|
||||||
|
|
||||||
|
var tTopLeft = RectTransformUtility.WorldToScreenPoint(pCam, tWorldCorners[1]);
|
||||||
|
var tBottomRight = RectTransformUtility.WorldToScreenPoint(pCam, tWorldCorners[3]);
|
||||||
|
var tWidth = Mathf.Abs(tBottomRight.x - tTopLeft.x);
|
||||||
|
var tHeight = Mathf.Abs(tBottomRight.y - tTopLeft.y);
|
||||||
|
return new NativeAdPosition
|
||||||
|
{
|
||||||
|
X = (int)tTopLeft.x,
|
||||||
|
Y = (int)(Screen.height - tTopLeft.y),
|
||||||
|
Width = (int)tWidth,
|
||||||
|
Height = (int)tHeight,
|
||||||
|
NativeTemplateStyle = nativeTemplateStyle
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
|
|
||||||
|
|
@ -37,17 +37,23 @@ namespace WZ
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
if (_initialized) return;
|
if (_initialized) return;
|
||||||
|
_initialized = true;
|
||||||
MobileAds.RaiseAdEventsOnUnityMainThread = true;
|
MobileAds.RaiseAdEventsOnUnityMainThread = true;
|
||||||
|
//
|
||||||
MobileAds.Initialize(initStatus =>
|
MobileAds.Initialize(initStatus =>
|
||||||
{
|
{
|
||||||
if (_bannerAdUnits.Count > 0) LoadBanner();
|
if (_bannerAdUnits.Count > 0) LoadBanner();
|
||||||
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
||||||
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
||||||
if(_splashAdUnits.Count > 0) AdsSplashManager.Instance.InitSplash();
|
if(_splashAdUnits.Count > 0) AdsSplashManager.Instance.InitSplash();
|
||||||
_initialized = true;
|
|
||||||
LoggerUtils.Debug("[Admob] init success");
|
LoggerUtils.Debug("[Admob] init success");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_nativeAdUnits.Add("ca-app-pub-3940256099942544/2247696110");
|
||||||
|
if (_nativeAdUnits.Count > 0)
|
||||||
|
{
|
||||||
|
LoadNative();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshAdsData()
|
public void RefreshAdsData()
|
||||||
|
|
@ -294,24 +300,31 @@ namespace WZ
|
||||||
#region 原生广告功能
|
#region 原生广告功能
|
||||||
public void LoadNative()
|
public void LoadNative()
|
||||||
{
|
{
|
||||||
}
|
_admobNativeAdManager?.Destroy();
|
||||||
public double GetNativeRevenue()
|
_admobNativeAdManager = new AdmobNativeAdManager();
|
||||||
{
|
_admobNativeAdManager.InitializeAdUnits(
|
||||||
return 0;
|
_nativeAdUnits
|
||||||
}
|
);
|
||||||
public void DisplayNative(NativeAdPosition position)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsNativeAvailable()
|
public bool IsNativeAvailable(string adUnitId)
|
||||||
{
|
{
|
||||||
return false;
|
return _admobNativeAdManager.IsAdAvailable(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveNative()
|
public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position)
|
||||||
{
|
{
|
||||||
|
_admobNativeAdManager.ShowAd(position, adUnitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNative(string adUnitId)
|
||||||
|
{
|
||||||
|
_admobNativeAdManager.RemoveNative(adUnitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetNativeRevenue(string adUnitId)
|
||||||
|
{
|
||||||
|
return _admobBannerAdManager.GetAdRevenue(adUnitId);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,14 @@ namespace WZ
|
||||||
|
|
||||||
NativeOverlayAd.Load(adUnitId, new AdRequest(), new NativeAdOptions(), (NativeOverlayAd ad, LoadAdError error) =>
|
NativeOverlayAd.Load(adUnitId, new AdRequest(), new NativeAdOptions(), (NativeOverlayAd ad, LoadAdError error) =>
|
||||||
{
|
{
|
||||||
|
LoggerUtils.Debug($"[Admob] Native Ad unit {adUnitId} loaded {ad} error {error}");
|
||||||
if (error != null || ad == null)
|
if (error != null || ad == null)
|
||||||
{
|
{
|
||||||
_retryCounters[adUnitId]++;
|
if (!_retryCounters.TryAdd(adUnitId, 0))
|
||||||
|
{
|
||||||
|
_retryCounters[adUnitId]++;
|
||||||
|
}
|
||||||
|
|
||||||
var retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
var retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
||||||
TimerUtils.Instance.DelayExecute((float)retryDelay, () => { LoadAd(adUnitId); });
|
TimerUtils.Instance.DelayExecute((float)retryDelay, () => { LoadAd(adUnitId); });
|
||||||
LoggerUtils.Debug("[Admob] Native ad failed to load an ad with error : " + error + " \n retryDelay :" + retryDelay);
|
LoggerUtils.Debug("[Admob] Native ad failed to load an ad with error : " + error + " \n retryDelay :" + retryDelay);
|
||||||
|
|
@ -119,7 +124,7 @@ namespace WZ
|
||||||
|
|
||||||
|
|
||||||
// 检查特定广告位是否可用
|
// 检查特定广告位是否可用
|
||||||
private bool IsAdAvailable(string adUnitId)
|
public bool IsAdAvailable(string adUnitId)
|
||||||
{
|
{
|
||||||
return _nativeAds.TryGetValue(adUnitId, out _);
|
return _nativeAds.TryGetValue(adUnitId, out _);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,23 +179,23 @@ namespace WZ
|
||||||
|
|
||||||
|
|
||||||
#region 原生广告
|
#region 原生广告
|
||||||
public bool IsNativeAdReady()
|
public bool IsNativeAdReady(string adUnitId)
|
||||||
{
|
{
|
||||||
return AdmobAdsManager.Instance.IsNativeAvailable();
|
return AdmobAdsManager.Instance.IsNativeAvailable(adUnitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowNativeAd(NativeAdPosition position)
|
public void ShowNativeAd(string _adPos, string adUnitId, NativeAdPosition position)
|
||||||
{
|
{
|
||||||
if (IsNativeAdReady())
|
if (IsNativeAdReady(adUnitId))
|
||||||
{
|
{
|
||||||
AdmobAdsManager.Instance.DisplayNative(position);
|
AdmobAdsManager.Instance.DisplayNative(_adPos, adUnitId, position);
|
||||||
AdPlayCountManager.IncrementAdPlayCount(AdsType.Native);
|
AdPlayCountManager.IncrementAdPlayCount(AdsType.Native);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveNativeAd()
|
public void RemoveNativeAd(string adUnitId)
|
||||||
{
|
{
|
||||||
AdmobAdsManager.Instance.RemoveNative();
|
AdmobAdsManager.Instance.RemoveNative(adUnitId);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,10 +217,25 @@ namespace WZ
|
||||||
|
|
||||||
#region 原生广告功能
|
#region 原生广告功能
|
||||||
public void LoadNative() { }
|
public void LoadNative() { }
|
||||||
public bool IsNativeAvailable() { return false; }
|
public bool IsNativeAvailable(string adUnitId)
|
||||||
public void DisplayNative(NativeAdPosition position) { }
|
{
|
||||||
public void RemoveNative() { }
|
return false;
|
||||||
public double GetNativeRevenue() { return 0; }
|
}
|
||||||
|
|
||||||
|
public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNative(string adUnitId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetNativeRevenue(string adUnitId)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -271,10 +271,24 @@ namespace WZ
|
||||||
|
|
||||||
#region 原生广告功能
|
#region 原生广告功能
|
||||||
public void LoadNative() { }
|
public void LoadNative() { }
|
||||||
public double GetNativeRevenue() { return 0; }
|
public bool IsNativeAvailable(string adUnitId)
|
||||||
public void DisplayNative(NativeAdPosition position) { }
|
{
|
||||||
public bool IsNativeAvailable() { return false; }
|
return false;
|
||||||
public void RemoveNative() { }
|
}
|
||||||
|
|
||||||
|
public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNative(string adUnitId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetNativeRevenue(string adUnitId)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,26 @@ namespace WZ
|
||||||
|
|
||||||
#region 原生广告功能
|
#region 原生广告功能
|
||||||
public void LoadNative() { }
|
public void LoadNative() { }
|
||||||
|
public bool IsNativeAvailable(string adUnitId)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNative(string adUnitId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetNativeRevenue(string adUnitId)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public double GetNativeRevenue() { return 0; }
|
public double GetNativeRevenue() { return 0; }
|
||||||
public void DisplayNative(NativeAdPosition position) { }
|
public void DisplayNative(NativeAdPosition position) { }
|
||||||
public bool IsNativeAvailable() { return false; }
|
public bool IsNativeAvailable() { return false; }
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,46 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using GoogleMobileAds.Api;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using WZ;
|
using WZ;
|
||||||
|
|
||||||
public class Test : MonoBehaviour
|
public class Test : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private List<string> _rewardedAdUnits = new List<string>();
|
||||||
|
|
||||||
private List<string> _rewardedAdUnits = new List<string>();
|
|
||||||
public void OnShowAd()
|
public void OnShowAd()
|
||||||
{
|
{
|
||||||
AppSDKManager.Instance.Init(null);
|
AppSDKManager.Instance.Init(null);
|
||||||
// KwaiAdsManager.Instance.ShowRewardAd();
|
// KwaiAdsManager.Instance.ShowRewardAd();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnShowInterstitial()
|
public void OnShowInterstitial()
|
||||||
{
|
{
|
||||||
KwaiAdsManager.Instance.OnInterstitialCallback();
|
// KwaiAdsManager.Instance.OnInterstitialCallback();
|
||||||
|
var small = gameObject.transform.Find("NativeAd-small").GetComponent<RectTransform>();
|
||||||
|
var medium = gameObject.transform.Find("NativeAd-medium").GetComponent<RectTransform>();
|
||||||
|
// var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||||
|
// {
|
||||||
|
// TemplateId = NativeTemplateId.Medium
|
||||||
|
// }, medium);
|
||||||
|
|
||||||
|
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||||
|
{
|
||||||
|
TemplateId = NativeTemplateId.Small
|
||||||
|
}, small);
|
||||||
|
Debug.Log($"luojian admob native ad start show {small} medium {medium} X:{nativeAdPosition.X} Y:{nativeAdPosition.Y} Height :{nativeAdPosition.Height} Width:{nativeAdPosition.Width}");
|
||||||
|
if (AdsSDKManager.Instance.IsNativeAdReady("ca-app-pub-3940256099942544/2247696110"))
|
||||||
|
{
|
||||||
|
// var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
||||||
|
// {
|
||||||
|
// TemplateId = NativeTemplateId.Medium
|
||||||
|
// }, medium);
|
||||||
|
AdsSDKManager.Instance.ShowNativeAd("test", "ca-app-pub-3940256099942544/2247696110", nativeAdPosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("luojian admob native ad start show fail,not ready.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue