Commit f531f188 authored by zhangzhe's avatar zhangzhe

穿山甲广告

parent c4bc27cf
......@@ -49,8 +49,19 @@ public class CSJFeedUtil : MonoBehaviour
#elif UNITY_IOS
feedAd.Dispose();
feedAd = null;
#endif
if (lastEntity != null && lastCallBack != null)
{
var adSlot = new AdSlot.Builder()
.SetCodeId(lastEntity.codeId)
.SetImageAcceptedSize(Screen.width, 0)
.SetSupportDeepLink(true)
.SetOrientation(AdOrientation.Horizontal)
.SetAdCount(1) //请求广告数量为1到3条
.Build();
this.AdNative.LoadNativeExpressAd(adSlot, new CloseLoadFeedAdListener(lastEntity, lastCallBack));
}
#endif
}
}
......@@ -59,6 +70,9 @@ public class CSJFeedUtil : MonoBehaviour
/// </summary>
private static Queue<ExpressAd> feedAdCacheList = new Queue<ExpressAd>();
private static AdEntity lastEntity;
private static Action<bool> lastCallBack;
/// <summary>
/// 缓存加载FeedAd
/// </summary>
......@@ -66,17 +80,21 @@ public class CSJFeedUtil : MonoBehaviour
/// <param name="callback"></param>
public void LoadCacheFeedAd(AdEntity entity, Action<bool> callback)
{
lastEntity = entity;
lastCallBack = callback;
var adSlot = new AdSlot.Builder()
#if UNITY_IOS
.SetCodeId(entity.codeId)
.SetExpressViewAcceptedSize(Screen.width, 0)
.SetImageAcceptedSize(Screen.width, 0)
#else
.SetCodeId(entity.codeId)
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
.SetExpressViewAcceptedSize(Screen.width, 0)
.SetImageAcceptedSize(1080, 1920)
#endif
.SetSupportDeepLink(true)
.SetImageAcceptedSize(1080, 1920)
.SetOrientation(AdOrientation.Horizontal)
.SetAdCount(1) //请求广告数量为1到3条
.Build();
......@@ -85,19 +103,28 @@ public class CSJFeedUtil : MonoBehaviour
//FeedAd IOS 和 Android 相同
private ExpressAd feedAd;
// 判断是否是刘海屏
private static bool isX;
public static bool IsX
{
get => isX = !(Screen.width == 750 && Screen.height == 1334) && !(Screen.width == 1242 && Screen.height == 2208) && !(Screen.width == 640 && Screen.height == 1136) && !(Screen.width == 1080 && Screen.height == 1920);
set => isX = value;
}
/// <summary>
/// 展示缓存的FeedAd
/// </summary>
/// <param name="entity"></param>
public void ShowCacheFeedAd(AdEntity entity,Action<bool> callback)
{
CloseFeedAd();
//CloseFeedAd();
if (feedAdCacheList.Count > 0)
{
feedAd = feedAdCacheList.Dequeue();
#if UNITY_IOS
int x = 0;
int y = 100;
float x = 0;
float y = Screen.height - (Screen.width * 275.5f / 375) - (IsX ? 45 : 0);
//if (y == 0)
//{
// y = 100; // 防止Demo里刘海遮挡
......@@ -162,6 +189,44 @@ public class CSJFeedUtil : MonoBehaviour
}
/// <summary>
/// 代替关闭方法的加载方法监听
/// </summary>
private sealed class CloseLoadFeedAdListener : IExpressAdListener
{
private AdEntity entity;
private Action<bool> callback;
public CloseLoadFeedAdListener(AdEntity entity, Action<bool> callback)
{
this.entity = entity;
this.callback = callback;
}
public void OnError(int code, string message)
{
callback(false);
}
public void OnExpressAdLoad(List<ExpressAd> ads)
{
}
#if UNITY_IOS
public void OnExpressBannerAdLoad(ExpressBannerAd ad)
{
}
public void OnExpressInterstitialAdLoad(ExpressInterstitialAd ad)
{
}
#else
#endif
}
private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener
{
......
......@@ -726,22 +726,22 @@ public sealed class Example : MonoBehaviour
public void LoadExpressFeedAd()
{
//this.width = GameObject.Find("Canvas/Width").GetComponent<InputField>();
//this.height = GameObject.Find("Canvas/Height").GetComponent<InputField>();
this.width = GameObject.Find("Canvas/Width").GetComponent<InputField>();
this.height = GameObject.Find("Canvas/Height").GetComponent<InputField>();
//int width;
//int height;
//int.TryParse(this.width.text, out width);
//int.TryParse(this.height.text, out height);
int width;
int height;
int.TryParse(this.width.text, out width);
int.TryParse(this.height.text, out height);
//if (width == 0)
//{
// width = 375;
//}
//if (height == 0)
//{
// height = 0;
//}
if (width == 0)
{
width = Screen.width;
}
if (height == 0)
{
height = 0;
}
#if UNITY_IOS
......@@ -760,14 +760,14 @@ public sealed class Example : MonoBehaviour
var adSlot = new AdSlot.Builder()
#if UNITY_IOS
.SetCodeId("945870984")
.SetExpressViewAcceptedSize(Screen.width, 0)
.SetImageAcceptedSize(width, height)
#else
.SetCodeId("901121253")
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
.SetExpressViewAcceptedSize(350, 0)
.SetImageAcceptedSize(1080, 1920)
#endif
.SetSupportDeepLink(true)
.SetImageAcceptedSize(1080, 1920)
.SetOrientation(AdOrientation.Horizontal)
.SetAdCount(1) //请求广告数量为1到3条
.Build();
......@@ -775,6 +775,25 @@ public sealed class Example : MonoBehaviour
}
public void CloseExpressFeedAd()
{
#if UNITY_IOS
if (this.mExpressFeedad != null)
{
this.mExpressFeedad.Dispose();
this.mExpressFeedad = null;
}
#endif
}
// 判断是否是刘海屏
private static bool isX;
public static bool IsX
{
get => isX = !(Screen.width == 750 && Screen.height == 1334) && !(Screen.width == 1242 && Screen.height == 2208) && !(Screen.width == 640 && Screen.height == 1136) && !(Screen.width == 1080 && Screen.height == 1920);
set => isX = value;
}
/// <summary>
/// Show the expressFeed Ad.
/// </summary>
......@@ -800,10 +819,13 @@ public sealed class Example : MonoBehaviour
if (y == 0)
{
y = 100; // 防止Demo里刘海遮挡
this.mExpressFeedad.ShowExpressAd(x, Screen.height - (Screen.width * 275.5f / 375) + (IsX ? 45 : 0));
}
this.mExpressFeedad.ShowExpressAd(x, y);
else
{
this.mExpressFeedad.ShowExpressAd(x, y);
}
#else
if (this.mExpressFeedad == null)
{
......
......@@ -382,7 +382,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 788e2a3a769e26b459cd63d4a5de7d76, type: 3}
m_Name:
m_EditorClassIdentifier:
isTest: 0
isTest: 1
isShowLog: 1
XyDialog: {fileID: 0}
--- !u!1 &2010092450
......
......@@ -231,14 +231,14 @@ public class AdUtils
#endif
AdManager.Instance.CloseFeedAd();
#if UNITY_IOS
AdManager.Instance.LoadCacheFeedAd("bigimage");
AdManager.Instance.LoadCacheFeedAd("bigimage");
#endif
}
public static void showBanner(string action)
{
IsShowRewardAd = true;
#if UNITY_EDITOR
#if UNITY_EDITOR || UNITY_IOS
return;
#endif
AdManager.Instance.ShowCacheBannerAd("banner", action);
......
......@@ -478,12 +478,12 @@ public class DialogControl : MonoBehaviour
//EventUtils.OnEvent("addDiamond_click", "点击钻石加号");
AudioUtils.ins.PlayBtnAudio();
DiamondDialog.SetActive(true);
#if UNITY_IOS
moveDiamondDialog();
#else
//#if UNITY_IOS
// moveDiamondDialog();
//#else
Invoke("showAd",0.5f);
Invoke("moveDiamondDialog", 1f);
#endif
//#endif
HttpTool.Instance._Get("app/v1/wdlc/reward/diamond_by_video_status", parm, new Action<DiamondStatusBean>((bean) =>
{
......@@ -587,12 +587,12 @@ public class DialogControl : MonoBehaviour
AllSpeedDialog.SetActive(true);
allSpeedDesc.text = "所有作物成熟速度加" + bean.reduceMinute + "分钟";
useAllSpeedByVideoNumTv.text = "每天0点重置视频次数(剩余" + bean.todayVideoRemainingNum + "次)";
#if UNITY_IOS
moveAllSpeedDialog();
#else
//#if UNITY_IOS
// moveAllSpeedDialog();
//#else
Invoke("showAd", 0.5f);
Invoke("moveAllSpeedDialog", 1f);
#endif
//#endif
//HttpTool.Instance._Get("app/v1/game/reward_video/status", parm, new Action<VideoStatusBean>((bean) =>
//{
......@@ -641,11 +641,10 @@ public class DialogControl : MonoBehaviour
/// </summary>
public void OnClickCloseAllSpeedDialog()
{
AdUtils.closeFeedAd();
allspeedcontent.transform.localPosition -= new Vector3(0, 320, 0);
AudioUtils.ins.PlayBtnAudio();
AllSpeedDialog.SetActive(false);
AdUtils.closeFeedAd();
}
//使用及时雨
......
......@@ -34,12 +34,12 @@ public class StickDialog : MonoBehaviour
Debug.unityLogger.Log("显示害虫弹窗"+arg);
StickDialogObj.SetActive(true);
#if UNITY_IOS
moveDialog();
#else
//#if UNITY_IOS
// moveDialog();
//#else
AdUtils.showFeedAd("stick");
Invoke("moveDialog", 1f);
#endif
//#endif
}
private void moveDialog()
{
......
......@@ -5,16 +5,22 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
- enabled: 0
path: Assets/Game/Main/Scenes/InitScene.unity
guid: 902436d14e36d4d42921eab701175b51
- enabled: 1
- enabled: 0
path: Assets/Game/Splash/Splash.unity
guid: 37af8cf3fb373478ab04e3ee2f3b700a
- enabled: 1
- enabled: 0
path: Assets/Game/Main/Scenes/CrazyCar.unity
guid: 2ae344869669f6641a05481805b94e98
- enabled: 0
path: Assets/Base/AdSDK/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 0
path: Assets/Base/AdSDK/AD/CSJ/Example/Example.unity
guid: 1e4f8457b1266154e80399e42b932ceb
- enabled: 1
path: Assets/Base/AdSDK/AD/GDT/UnionDemo/UnionExample.unity
guid: 6c963ae210fa3c3438c2f6770ee81fc9
m_configObjects: {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment