Commit 881cbf7e authored by 王雪伟's avatar 王雪伟

Unity广告SDK 1.0.0

parent 0677490a
...@@ -46,14 +46,17 @@ public class AdManager ...@@ -46,14 +46,17 @@ public class AdManager
private string AdConfigUrl = "v1/fetch/adAppIds"; private string AdConfigUrl = "v1/fetch/adAppIds";
private string AdLoadUrl = "v4/ads"; private string AdLoadUrl = "v4/ads";
private bool IsFirstLoadRewardAd = false;
private bool IsFirstLoadFSAd = false;
public void InitAd() public void InitAd()
{ {
IsFirstLoadRewardAd = true;
IsFirstLoadFSAd = true;
//paras.Clear(); //paras.Clear();
//paras.Add("pkg", "com.ym.xynt"); //paras.Add("pkg", "com.ym.xynt");
//获取广告配置 //获取广告配置
Dictionary<string, string> paras = new Dictionary<string, string>(); Dictionary<string, object> paras = new Dictionary<string, object>();
HttpTool.Instance._Get(AdConfigUrl, paras, new Action<List<AdIdConfig>>((AdConfigList) => HttpTool.Instance._GetAD(AdConfigUrl, paras, new Action<List<AdIdConfig>>((AdConfigList) =>
{ {
foreach (AdIdConfig id in AdConfigList) foreach (AdIdConfig id in AdConfigList)
{ {
...@@ -75,7 +78,7 @@ public class AdManager ...@@ -75,7 +78,7 @@ public class AdManager
}), new Action<string, string>((code, errMsg) => }), new Action<string, string>((code, errMsg) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "AdInit 请求失败" + errMsg); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, code+"AdInit 请求失败" + errMsg);
})); }));
} }
...@@ -91,33 +94,70 @@ public class AdManager ...@@ -91,33 +94,70 @@ public class AdManager
listener.onError("没有初始化"); listener.onError("没有初始化");
return; return;
} }
Dictionary<string, string> paras = new Dictionary<string, string>(); Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("slotName", "splash"); paras.Add("slotName", "splash");
HttpTool.Instance._Get(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) => HttpTool.Instance._GetAD(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 请求成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 请求成功");
if (AdConfigList != null && AdConfigList.Count > 0) if (AdConfigList != null && AdConfigList.Count > 0)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 开始加载"); //Splash数据
mLoadSplashPlatform(AdConfigList[0], listener, new Action<bool>((bl) => List<AdEntity> bannerAdList = new List<AdEntity>();
bannerAdList.Add(AdConfigList[0]);
if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0)
{
bannerAdList.AddRange(AdConfigList[0].backups);
}
//加载Splash广告
mLoadSplashAd("splash", listener, bannerAdList);
}
}), new Action<string, string>((code, errMsg) =>
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 请求失败" + errMsg);
}));
}
/// <summary>
/// 根据广告List开始加载Splash
/// </summary>
private Action<bool> SplashAdCallBack;
private void mLoadSplashAd(string sloatName, ZXADSplashListener listener, List<AdEntity> adList)
{
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash没有广告数据");
return;
}
List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0];
//移除第一条数据
totalEntityList.RemoveAt(0);
SplashAdCallBack = new Action<bool>((bl) =>
{ {
if (bl) if (bl)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash成功 " + entity.adPlatform + " CodeID " + entity.codeId);
} }
else else
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 失败"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0)
{
entity = totalEntityList[0];
totalEntityList.RemoveAt(0);
mLoadSplashPlatform(entity, listener,SplashAdCallBack);
} }
})); }
});
mLoadSplashPlatform(entity, listener,SplashAdCallBack);
} }
}), new Action<string, string>((code, errMsg) =>
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Splash 请求失败" + errMsg);
}));
}
/// <summary> /// <summary>
/// 分平台加载开屏广告 /// 分平台加载开屏广告
/// </summary> /// </summary>
...@@ -141,219 +181,552 @@ public class AdManager ...@@ -141,219 +181,552 @@ public class AdManager
//==================================================================Banner START================================================
/// <summary> /// <summary>
/// 缓存Banner广告 /// 缓存Banner广告
/// </summary> /// </summary>
public void LoadCacheBannerAd() public void LoadCacheBannerAd(string slotName)
{ {
Dictionary<string, string> paras = new Dictionary<string, string>(); Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("slotName", "splash"); paras.Add("slotName", slotName);
HttpTool.Instance._Get(AdLoadUrl, paras, new Action<List<AdIdConfig>>((AdConfigList) => HttpTool.Instance._GetAD(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) =>
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Banner 请求成功");
if (AdConfigList != null && AdConfigList.Count > 0)
{
//Banner数据
List<AdEntity> bannerAdList = new List<AdEntity>();
bannerAdList.Add(AdConfigList[0]);
if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0)
{ {
bannerAdList.AddRange(AdConfigList[0].backups);
}
//加载Banner广告
mLoadBannerCacheAd(slotName, bannerAdList);
}
}), new Action<string, string>((code, errMsg) =>
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Banner请求失败" + errMsg);
}));
}
}), new Action<string, string>((code, errMsg) =>
/// <summary>
/// 根据广告List开始加载Banner缓存
/// </summary>
private Action<bool> BannerAdCallBack;
private void mLoadBannerCacheAd(string sloatName, List<AdEntity> adList)
{
if (adList == null || adList.Count == 0)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Banner没有广告数据");
return;
}
List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0];
})); //移除第一条数据
GDTBannerAdUtil.Instance.LoadCacheBannerAd(null, new Action<bool>((bl) => totalEntityList.RemoveAt(0);
BannerAdCallBack = new Action<bool>((bl) =>
{ {
if (bl) if (bl)
{ {
Debug.Log("GDT Banner 缓存成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Banner缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
//保存Banner缓存数据
ZXADConfig.Instance.SetAdCache(sloatName, entity, "");
} }
else else
{ {
Debug.Log("GDT Banner 缓存失败"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Banner缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0)
{
entity = totalEntityList[0];
totalEntityList.RemoveAt(0);
mLoadCacheBannerAdPlatform(entity, BannerAdCallBack);
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "开始缓存Banner");
mLoadCacheBannerAdPlatform(entity, BannerAdCallBack);
} }
}));
//CSJBannerUtil.Instance.LoadCacheBannerAd(null, new Action<bool>((bl) =>
//{
// if (bl)
// {
// Debug.Log("GDT Banner 缓存成功");
// }
// else
// {
// Debug.Log("GDT Banner 缓存失败");
// }
//}));
private void mLoadCacheBannerAdPlatform(AdEntity entity, Action<bool> callback)
{
switch (entity.adPlatform)
{
case ZXADConfig.PLANTFORM_AD_TT:
//穿山甲Banner广告加载
CSJBannerUtil.Instance.LoadCacheBannerAd(entity, callback);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通Banner广告加载
GDTBannerAdUtil.Instance.LoadCacheBannerAd(entity, callback);
break;
} }
}
/// <summary> /// <summary>
/// show缓存的Banner /// 展示缓存的Banner广告
/// </summary> /// </summary>
public void ShowCacheBannerAd() public void ShowCacheBannerAd(string slotName)
{
AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName, "");
if (entity != null)
{
ZXADConfig.Instance.RemoveAdCache(slotName, "");
mShowCacheBannerAdPlatform(entity, new Action<bool>((bl) =>
{
if (bl)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "展示Banner成功 " + entity.adPlatform + " CodeId" + entity.codeId);
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "展示Banner失败 " + entity.adPlatform + " CodeId" + entity.codeId);
}
}));
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "展示Banner失败 缓存的信息为null");
}
}
private void mShowCacheBannerAdPlatform(AdEntity entity, Action<bool> callback)
{
switch (entity.adPlatform)
{ {
GDTBannerAdUtil.Instance.ShowCacheBannerAd(null); case ZXADConfig.PLANTFORM_AD_TT:
//CSJBannerUtil.Instance.ShowCacheBannerAd(); //穿山甲Banner广告加载
CSJBannerUtil.Instance.ShowCacheBannerAd(entity,callback);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通Banner广告加载
GDTBannerAdUtil.Instance.ShowCacheBannerAd(entity, callback);
break;
}
} }
//==================================================================Banner END================================================
//==================================================================大图START================================================
/// <summary> /// <summary>
/// 缓存大图广告 /// 缓存大图广告
/// </summary> /// </summary>
public void LoadCacheFeedAd() public void LoadCacheFeedAd(string slotName)
{ {
Dictionary<string, string> paras = new Dictionary<string, string>(); Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("slotName", "bigimage"); paras.Add("slotName", slotName);
HttpTool.Instance._Get(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) => HttpTool.Instance._GetAD(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Feed 请求成功");
if (AdConfigList != null && AdConfigList.Count > 0)
{
//插屏大图数据
List<AdEntity> feedAdList = new List<AdEntity>();
feedAdList.Add(AdConfigList[0]);
if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0)
{
feedAdList.AddRange(AdConfigList[0].backups);
}
//加载大图广告
mLoadFeedCacheAd(slotName, feedAdList);
}
}), new Action<string, string>((code, errMsg) => }), new Action<string, string>((code, errMsg) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "Feed 请求失败" + errMsg);
})); }));
//CSJFeedUtil.Instance.LoadCacheFeedAd(null, new Action<bool>((bl) => }
//{
// if (bl)
// {
// Debug.Log("CSJ Feed 缓存成功");
// }
// else
// {
// Debug.Log("CSJ Feed 缓存失败");
// }
//}));
GDTFeedAdUtil.Instance.LoadCacheFeedAd(null, new Action<bool>((bl) => /// <summary>
/// 根据广告List开始加载插屏缓存
/// </summary>
private Action<bool> FeedAdCallBack;
private void mLoadFeedCacheAd(string sloatName, List<AdEntity> adList)
{
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "大图没有广告数据");
return;
}
List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0];
//移除第一条数据
totalEntityList.RemoveAt(0);
FeedAdCallBack = new Action<bool>((bl) =>
{ {
if (bl) if (bl)
{ {
Debug.Log("GDT Feed 缓存成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "大图缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
//保存插屏缓存数据
ZXADConfig.Instance.SetAdCache(sloatName, entity, "");
} }
else else
{ {
Debug.Log("GDT Feed 缓存失败"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "大图缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0)
{
entity = totalEntityList[0];
totalEntityList.RemoveAt(0);
mLoadCacheFeedAdPlatform(entity, FeedAdCallBack);
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "开始缓存大图");
mLoadCacheFeedAdPlatform(entity, FeedAdCallBack);
} }
})); private void mLoadCacheFeedAdPlatform(AdEntity entity, Action<bool> callback)
{
switch (entity.adPlatform)
{
case ZXADConfig.PLANTFORM_AD_TT:
//穿山甲插屏广告加载
CSJFeedUtil.Instance.LoadCacheFeedAd(entity, callback);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通插屏广告加载
GDTFeedAdUtil.Instance.LoadCacheFeedAd(entity, callback);
break;
}
} }
/// <summary> /// <summary>
/// 展示缓存的大图广告 /// 展示缓存的大图广告
/// </summary> /// </summary>
public void ShowCacheFeedAd() public void ShowCacheFeedAd(string slotName)
{
AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName, "");
if (entity != null)
{ {
CSJFeedUtil.Instance.ShowCacheFeedAd(null); ZXADConfig.Instance.RemoveAdCache(slotName, "");
GDTFeedAdUtil.Instance.ShowCacheFeedAd(null); mShowCacheFeedAdPlatform(entity, new Action<bool>((bl) =>
{
if (bl)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "展示大图成功 " + entity.adPlatform + " CodeId" + entity.codeId);
} }
/// <summary> else
/// 缓存插屏广告
/// </summary>
public void LoadCacheInterstitialAd()
{ {
Dictionary<string, string> paras = new Dictionary<string, string>(); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "展示大图失败 " + entity.adPlatform + " CodeId" + entity.codeId);
paras.Add("slotName", "splash"); }
HttpTool.Instance._Get(AdLoadUrl, paras, new Action<List<AdIdConfig>>((AdConfigList) => }));
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "展示大图失败 缓存的信息为null");
}
}
private void mShowCacheFeedAdPlatform(AdEntity entity, Action<bool> callback)
{
switch (entity.adPlatform)
{ {
case ZXADConfig.PLANTFORM_AD_TT:
//穿山甲大图广告加载
CSJFeedUtil.Instance.ShowCacheFeedAd(entity,callback);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通大图广告加载
GDTFeedAdUtil.Instance.ShowCacheFeedAd(entity, callback);
break;
}
}
//==================================================================大图End================================================
//==================================================================插屏START================================================
/// <summary>
/// 缓存插屏广告
/// </summary>
public void LoadCacheInterstitialAd(string slotName)
{
Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("slotName", slotName);
HttpTool.Instance._GetAD(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) =>
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "插屏广告请求成功");
if (AdConfigList != null && AdConfigList.Count > 0)
{
//插屏广告数据
List<AdEntity> interAdList = new List<AdEntity>();
interAdList.Add(AdConfigList[0]);
if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0)
{
interAdList.AddRange(AdConfigList[0].backups);
}
//加载插屏广告
mLoadInterstitialCacheAd(slotName, interAdList);
}
}), new Action<string, string>((code, errMsg) => }), new Action<string, string>((code, errMsg) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "插屏请求失败" + errMsg);
})); }));
//CSJInterstitialUtil.Instance.LoadCacheInterstitialAd(null, new Action<bool>((bl) => }
//{
// if (bl)
// {
// Debug.Log("CSJ 插屏 缓存成功");
// }
// else
// {
// Debug.Log("CSJ 插屏 缓存失败");
// }
//}));
GDTInterstitialAdUtil.Instance.LoadCacheInterstitialAd(null, new Action<bool>((bl) => /// <summary>
/// 根据广告List开始加载插屏缓存
/// </summary>
private Action<bool> InterstitialAdCallBack;
private void mLoadInterstitialCacheAd(string sloatName, List<AdEntity> adList)
{
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "插屏没有广告数据");
return;
}
List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0];
//移除第一条数据
totalEntityList.RemoveAt(0);
InterstitialAdCallBack = new Action<bool>((bl) =>
{ {
if (bl) if (bl)
{ {
Debug.Log("GDT 插屏 缓存成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "插屏缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
//保存插屏缓存数据
ZXADConfig.Instance.SetAdCache(sloatName, entity, "");
} }
else else
{ {
Debug.Log("GDT 插屏 缓存失败"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "插屏缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0)
{
entity = totalEntityList[0];
totalEntityList.RemoveAt(0);
mLoadInterstitialAdPlatform(entity, InterstitialAdCallBack);
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "开始缓存插屏");
mLoadInterstitialAdPlatform(entity, InterstitialAdCallBack);
} }
})); private void mLoadInterstitialAdPlatform(AdEntity entity,Action<bool> callback)
{
switch (entity.adPlatform)
{
case ZXADConfig.PLANTFORM_AD_TT:
//穿山甲插屏广告加载
CSJInterstitialUtil.Instance.LoadCacheInterstitialAd(entity, callback);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通插屏广告加载
GDTInterstitialAdUtil.Instance.LoadCacheInterstitialAd(entity, callback);
break;
}
} }
/// <summary> /// <summary>
/// 播放缓存的插屏广告 /// 播放缓存的插屏广告
/// </summary> /// </summary>
public void PlayCacheInterstitialAd() public void PlayCacheInterstitialAd(string slotName)
{
AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName,"");
if (entity != null)
{
ZXADConfig.Instance.RemoveAdCache(slotName, "");
mPlayCacheInterstitialAdPlatform(entity, new Action<bool>((bl) =>
{
if (bl)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "播放全屏视频成功 " + entity.adPlatform + " CodeId" + entity.codeId);
}
else
{ {
//CSJInterstitialUtil.Instance.PlayCacheInterstitialAd(null); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "播放全屏视频失败 " + entity.adPlatform + " CodeId" + entity.codeId);
GDTInterstitialAdUtil.Instance.PlayCacheInterstitialAd(null); }
}));
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "播放全屏视频失败 缓存的信息为null");
}
}
private void mPlayCacheInterstitialAdPlatform(AdEntity entity,Action<bool> callback)
{
switch (entity.adPlatform)
{
case ZXADConfig.PLANTFORM_AD_TT:
//穿山甲插屏广告加载
CSJInterstitialUtil.Instance.PlayCacheInterstitialAd(entity,callback);
break;
case ZXADConfig.PLANTFORM_AD_GDT:
//广点通插屏广告加载
GDTInterstitialAdUtil.Instance.PlayCacheInterstitialAd(entity,callback);
break;
}
} }
//==================================================================插屏END================================================
//==================================================================全屏视频Start================================================
/// <summary> /// <summary>
/// 缓存全屏视频广告 /// 缓存全屏视频广告
/// </summary> /// </summary>
public void LoadCacheFSVideoAd(string slotName) public void LoadCacheFSVideoAd(string slotName)
{ {
Dictionary<string, string> paras = new Dictionary<string, string>(); Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("slotName", "fullvideo"); paras.Add("slotName", slotName);
HttpTool.Instance._Get(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) => HttpTool.Instance._GetAD(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频请求成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频请求成功");
if (AdConfigList != null && AdConfigList.Count > 0) if (AdConfigList != null && AdConfigList.Count > 0)
{ {
List<AdEntity> rewardAdList = new List<AdEntity>(); //A组数据
rewardAdList.Add(AdConfigList[0]); List<AdEntity> fsAdList_A = new List<AdEntity>();
fsAdList_A.Add(AdConfigList[0]);
if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0) if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0)
{ {
rewardAdList.AddRange(AdConfigList[0].backups); fsAdList_A.AddRange(AdConfigList[0].backups);
} }
mLoadFSVideoCacheAd_A(slotName, rewardAdList); //A组没有缓存数据
if (ZXADConfig.Instance.GetAdCache(slotName, "A") == null)
{
mLoadFSVideoCacheAd_A(slotName, fsAdList_A);
} }
//B组数据
if (AdConfigList[0].bgroup != null)
{
List<AdEntity> fsAdList_B = new List<AdEntity>();
fsAdList_B.Add(AdConfigList[0].bgroup);
if (AdConfigList[0].bgroup.backups != null && AdConfigList[0].bgroup.backups.Count > 0)
{
fsAdList_B.AddRange(AdConfigList[0].bgroup.backups);
}
//B组没有缓存数据
if (ZXADConfig.Instance.GetAdCache(slotName, "B") == null)
{
mLoadFSVideoCacheAd_B(slotName, fsAdList_B);
}
}
else
{
Debug.unityLogger.Log("B组数据为NULL");
}
}
}), new Action<string, string>((code, errMsg) => }), new Action<string, string>((code, errMsg) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频请求失败"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频请求失败"+errMsg);
})); }));
} }
/// <summary> /// <summary>
/// 根据广告List开始加载全屏视频缓存 /// 根据广告List开始加载全屏视频缓存A
/// </summary> /// </summary>
private Action<bool> FSVideoAdCallBack; private Action<bool> FSVideoAdCallBackA;
private void mLoadFSVideoCacheAd_A(string sloatName, List<AdEntity> adList) private void mLoadFSVideoCacheAd_A(string sloatName, List<AdEntity> adList)
{ {
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频A组没有数据");
return;
}
if (IsFirstLoadFSAd)
{
//第一次预加载 A组进行逆序加载
IsFirstLoadFSAd = false;
adList.Reverse();
}
List<AdEntity> totalEntityList = adList; List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0]; AdEntity entity = totalEntityList[0];
//移除第一条数据 //移除第一条数据
totalEntityList.RemoveAt(0); totalEntityList.RemoveAt(0);
FSVideoAdCallBack = new Action<bool>((bl) => FSVideoAdCallBackA = new Action<bool>((bl) =>
{ {
if (bl) if (bl)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频A组缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
ZXADConfig.Instance.SetAdCache(sloatName, entity, "A"); ZXADConfig.Instance.SetAdCache(sloatName, entity, "A");
} }
else else
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频A组缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0) if (totalEntityList.Count > 0)
{ {
entity = totalEntityList[0]; entity = totalEntityList[0];
totalEntityList.RemoveAt(0); totalEntityList.RemoveAt(0);
mLoadFSVideoAdPlatform(entity, FSVideoAdCallBack); mLoadFSVideoAdPlatform(entity, FSVideoAdCallBackA);
} }
} }
}); });
mLoadFSVideoAdPlatform(entity, FSVideoAdCallBack); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "A开始缓存全屏视频");
mLoadFSVideoAdPlatform(entity, FSVideoAdCallBackA);
} }
/// <summary>
/// 根据广告List开始加载全屏视频缓存B
/// </summary>
private Action<bool> FSVideoAdCallBackB;
private void mLoadFSVideoCacheAd_B(string sloatName, List<AdEntity> adList)
{
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频B组没有数据");
return;
}
List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0];
//移除第一条数据
totalEntityList.RemoveAt(0);
FSVideoAdCallBackB = new Action<bool>((bl) =>
{
if (bl)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频B组缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
ZXADConfig.Instance.SetAdCache(sloatName, entity, "B");
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频B组缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0)
{
entity = totalEntityList[0];
totalEntityList.RemoveAt(0);
mLoadFSVideoAdPlatform(entity, FSVideoAdCallBackB);
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "B开始缓存全屏视频");
mLoadFSVideoAdPlatform(entity, FSVideoAdCallBackB);
}
/// <summary> /// <summary>
/// 全屏广告根据广告信息选择加载广告的平台 /// 全屏广告根据广告信息选择加载广告的平台
/// </summary> /// </summary>
...@@ -382,12 +755,42 @@ public class AdManager ...@@ -382,12 +755,42 @@ public class AdManager
public void PlayCacheFSVideoAd(string slotName, string actionName, ZXADFullScreenVideoListener listener) public void PlayCacheFSVideoAd(string slotName, string actionName, ZXADFullScreenVideoListener listener)
{ {
AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName, "A"); AdEntity entity = null;
//AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName,"B");
AdEntity entityA = ZXADConfig.Instance.GetAdCache(slotName, "A");
AdEntity entityB = ZXADConfig.Instance.GetAdCache(slotName, "B");
if (entityA != null && entityB != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频 A组 B组 都有缓存数据");
if (entityA.codePrice > entityB.codePrice)
{
entity = entityA;
ZXADConfig.Instance.RemoveAdCache(slotName, "A");
}
else
{
entity = entityB;
ZXADConfig.Instance.RemoveAdCache(slotName, "B");
}
}
else if (entityA != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频 A组 有缓存数据");
entity = entityA;
ZXADConfig.Instance.RemoveAdCache(slotName, "A");
}
else if (entityB != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "全屏视频 B组 有缓存数据");
entity = entityB;
ZXADConfig.Instance.RemoveAdCache(slotName, "B");
}
if (entity != null) if (entity != null)
{ {
mPlayCacheFSVodeoAdPlatform(entity, listener, new Action<bool>((bl) => { mPlayCacheFSVodeoAdPlatform(entity, listener, new Action<bool>((bl) =>
{
if (bl) if (bl)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "播放全屏视频成功 " + entity.adPlatform + " CodeId" + entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "播放全屏视频成功 " + entity.adPlatform + " CodeId" + entity.codeId);
...@@ -422,12 +825,12 @@ public class AdManager ...@@ -422,12 +825,12 @@ public class AdManager
//==================================================================全屏视频END================================================
//==================================================================激励视频Start================================================
/// <summary> /// <summary>
...@@ -435,57 +838,136 @@ public class AdManager ...@@ -435,57 +838,136 @@ public class AdManager
/// </summary> /// </summary>
public void LoadCacheRewardVideoAd(string slotName) public void LoadCacheRewardVideoAd(string slotName)
{ {
Dictionary<string, string> paras = new Dictionary<string, string>(); Dictionary<string, object> paras = new Dictionary<string, object>();
paras.Add("slotName", "video"); paras.Add("slotName", slotName);
HttpTool.Instance._Get(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) => HttpTool.Instance._GetAD(AdLoadUrl, paras, new Action<List<AdEntity>>((AdConfigList) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频请求成功"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频请求成功");
if (AdConfigList != null && AdConfigList.Count > 0) if (AdConfigList != null && AdConfigList.Count > 0)
{ {
List<AdEntity> rewardAdList = new List<AdEntity>(); //A组数据
rewardAdList.Add(AdConfigList[0]); List<AdEntity> rewardAdList_A = new List<AdEntity>();
rewardAdList_A.Add(AdConfigList[0]);
if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0) if (AdConfigList[0].backups != null && AdConfigList[0].backups.Count > 0)
{ {
rewardAdList.AddRange(AdConfigList[0].backups); rewardAdList_A.AddRange(AdConfigList[0].backups);
}
//A组没有缓存数据
if (ZXADConfig.Instance.GetAdCache(slotName, "A") == null)
{
mLoadRewardVideoCacheAd_A(slotName, rewardAdList_A);
}
//B组数据
if (AdConfigList[0].bgroup != null)
{
List<AdEntity> rewardAdList_B = new List<AdEntity>();
rewardAdList_B.Add(AdConfigList[0].bgroup);
if (AdConfigList[0].bgroup.backups != null && AdConfigList[0].bgroup.backups.Count > 0)
{
rewardAdList_B.AddRange(AdConfigList[0].bgroup.backups);
}
//B组没有缓存数据
if (ZXADConfig.Instance.GetAdCache(slotName, "B") == null)
{
mLoadRewardVideoCacheAd_B(slotName, rewardAdList_B);
}
}
else
{
Debug.unityLogger.Log("B组数据为NULL");
} }
mLoadRewardVideoCacheAd_A(slotName, rewardAdList);
} }
}), new Action<string, string>((code, errMsg) => }), new Action<string, string>((code, errMsg) =>
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频请求失败"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频请求失败" + errMsg);
})); }));
} }
/// <summary> /// <summary>
/// 根据广告List开始加载激励视频缓存 /// 根据广告List开始加载激励视频缓存A组
/// </summary> /// </summary>
private Action<bool> rewardVideoAdCallBack; private Action<bool> rewardVideoAdCallBackA;
private void mLoadRewardVideoCacheAd_A(string sloatName, List<AdEntity> adList) private void mLoadRewardVideoCacheAd_A(string sloatName, List<AdEntity> adList)
{ {
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频A组没有数据");
return;
}
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "正序的第一个广告ID" + adList[0].codeId);
if (IsFirstLoadRewardAd)
{
//第一次预加载 A组进行逆序加载
IsFirstLoadRewardAd = false;
adList.Reverse();
}
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "反序的第一个广告ID" + adList[0].codeId);
List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0];
//移除第一条数据
totalEntityList.RemoveAt(0);
rewardVideoAdCallBackA = new Action<bool>((bl) =>
{
if (bl)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频A组缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
ZXADConfig.Instance.SetAdCache(sloatName, entity, "A");
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频A组缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0)
{
entity = totalEntityList[0];
totalEntityList.RemoveAt(0);
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBackA);
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "A开始缓存激励视频");
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBackA);
}
/// <summary>
/// 根据广告List开始加载激励视频缓存
/// </summary>
private Action<bool> rewardVideoAdCallBackB;
private void mLoadRewardVideoCacheAd_B(string sloatName, List<AdEntity> adList)
{
if (adList == null || adList.Count == 0)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频B组没有数据");
return;
}
List<AdEntity> totalEntityList = adList; List<AdEntity> totalEntityList = adList;
AdEntity entity = totalEntityList[0]; AdEntity entity = totalEntityList[0];
//移除第一条数据 //移除第一条数据
totalEntityList.RemoveAt(0); totalEntityList.RemoveAt(0);
rewardVideoAdCallBack = new Action<bool>((bl) => rewardVideoAdCallBackB = new Action<bool>((bl) =>
{ {
if (bl) if (bl)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频B组缓存成功 " + entity.adPlatform + " CodeID " + entity.codeId);
ZXADConfig.Instance.SetAdCache(sloatName, entity,"A"); ZXADConfig.Instance.SetAdCache(sloatName, entity, "B");
} }
else else
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频B组缓存失败 " + entity.adPlatform + " CodeID " + entity.codeId);
if (totalEntityList.Count > 0) if (totalEntityList.Count > 0)
{ {
entity = totalEntityList[0]; entity = totalEntityList[0];
totalEntityList.RemoveAt(0); totalEntityList.RemoveAt(0);
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBack); mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBackB);
} }
} }
}); });
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBack); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "B开始缓存激励视频");
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBackB);
} }
/// <summary> /// <summary>
/// 激励视频根据广告信息选择加载广告的平台 /// 激励视频根据广告信息选择加载广告的平台
/// </summary> /// </summary>
...@@ -493,6 +975,7 @@ public class AdManager ...@@ -493,6 +975,7 @@ public class AdManager
/// <param name="callback"></param> /// <param name="callback"></param>
private void mLoadRewardVideoAdPlatform(AdEntity entity, Action<bool> callback) private void mLoadRewardVideoAdPlatform(AdEntity entity, Action<bool> callback)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "开始加载" + entity.adPlatform + " CodeID " + entity.codeId);
switch (entity.adPlatform) switch (entity.adPlatform)
{ {
case ZXADConfig.PLANTFORM_AD_TT: case ZXADConfig.PLANTFORM_AD_TT:
...@@ -515,21 +998,64 @@ public class AdManager ...@@ -515,21 +998,64 @@ public class AdManager
/// <param name="listener">广告回调</param> /// <param name="listener">广告回调</param>
public void PlayCacheRewardVideoAd(string slotName, string actionName, ZXADRewardVideoListener listener) public void PlayCacheRewardVideoAd(string slotName, string actionName, ZXADRewardVideoListener listener)
{ {
AdEntity entity = null;
AdEntity entityA = ZXADConfig.Instance.GetAdCache(slotName, "A");
AdEntity entityB = ZXADConfig.Instance.GetAdCache(slotName, "B");
if (entityA != null && entityB != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频 A组 B组 都有缓存数据");
if (entityA.codePrice > entityB.codePrice)
{
entity = entityA;
ZXADConfig.Instance.RemoveAdCache(slotName, "A");
}
else
{
entity = entityB;
ZXADConfig.Instance.RemoveAdCache(slotName, "B");
}
//if (IsFirstLoadRewardAd)
//{
// Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频 第一次预加载,直接播放A组");
// //第一次预加载,直接播放A组
// IsFirstLoadRewardAd = false;
// entity = entityA;
// ZXADConfig.Instance.RemoveAdCache(slotName, "A");
//}
//else
//{
//}
}
else if (entityA != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频 A组 有缓存数据");
entity = entityA;
ZXADConfig.Instance.RemoveAdCache(slotName, "A");
}
else if (entityB != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "激励视频 B组 有缓存数据");
entity = entityB;
ZXADConfig.Instance.RemoveAdCache(slotName, "B");
}
AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName,"A");
//AdEntity entity = ZXADConfig.Instance.GetAdCache(slotName,"B");
if (entity != null) if (entity != null)
{ {
mPlayCacheRewardVodeoAdPlatform(entity, listener, new Action<bool>((bl)=> { mPlayCacheRewardVodeoAdPlatform(entity, listener, new Action<bool>((bl) =>
{
if (bl) if (bl)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG,"播放激励视频成功 " + entity.adPlatform + " CodeId" + entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "播放激励视频成功 " + entity.adPlatform + " CodeId" + entity.codeId);
} }
else else
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG,"播放激励视频失败 "+entity.adPlatform+" CodeId"+entity.codeId); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "播放激励视频失败 " + entity.adPlatform + " CodeId" + entity.codeId);
} }
})); }));
...@@ -541,7 +1067,7 @@ public class AdManager ...@@ -541,7 +1067,7 @@ public class AdManager
} }
} }
private void mPlayCacheRewardVodeoAdPlatform(AdEntity entity,ZXADRewardVideoListener listener,Action<bool> callback) private void mPlayCacheRewardVodeoAdPlatform(AdEntity entity, ZXADRewardVideoListener listener, Action<bool> callback)
{ {
switch (entity.adPlatform) switch (entity.adPlatform)
{ {
...@@ -558,5 +1084,6 @@ public class AdManager ...@@ -558,5 +1084,6 @@ public class AdManager
} }
//==================================================================激励视频END================================================
} }
...@@ -95,5 +95,13 @@ public class ZXADConfig ...@@ -95,5 +95,13 @@ public class ZXADConfig
return null; return null;
} }
public void RemoveAdCache(string slotName, string type)
{
if (AdCacheMap.ContainsKey(type + slotName))
{
AdCacheMap.Remove(type + slotName);
}
}
} }
...@@ -80,4 +80,8 @@ public class AdEntity ...@@ -80,4 +80,8 @@ public class AdEntity
/// ///
/// </summary> /// </summary>
public List<string> playcomplete_trackings { get; set; } public List<string> playcomplete_trackings { get; set; }
/// <summary>
///
/// </summary>
public AdEntity bgroup { get; set; }
} }
...@@ -6,5 +6,5 @@ public class AdIdConfig ...@@ -6,5 +6,5 @@ public class AdIdConfig
{ {
public string adPlatform; public string adPlatform;
public string codeAppId; public string codeAppId;
public string codeAppKey; //public string codeAppKey;
} }
...@@ -58,23 +58,24 @@ public class CSJBannerUtil ...@@ -58,23 +58,24 @@ public class CSJBannerUtil
{ {
var adSlot = new AdSlot.Builder() var adSlot = new AdSlot.Builder()
#if UNITY_IOS #if UNITY_IOS
.SetCodeId("900546269") .SetCodeId(entity.codeId)
#else #else
.SetCodeId("901121246") .SetCodeId(entity.codeId)
////期望模板广告view的size,单位dp,//高度按照实际rit对应宽高传入 ////期望模板广告view的size,单位dp,//高度按照实际rit对应宽高传入
#endif #endif
.SetExpressViewAcceptedSize(Screen.width, float.Parse(Screen.width.ToString()) / 600 * 90) //.SetExpressViewAcceptedSize(Screen.width, float.Parse(Screen.width.ToString()) / 600 * 90)
.SetExpressViewAcceptedSize(Screen.width, float.Parse(Screen.width.ToString()) /4)
.SetSupportDeepLink(true) .SetSupportDeepLink(true)
.SetImageAcceptedSize(1080, 1920) .SetImageAcceptedSize(1080, 1920)
.SetAdCount(1) .SetAdCount(1)
.SetOrientation(AdOrientation.Horizontal) .SetOrientation(AdOrientation.Horizontal)
.Build(); .Build();
Debug.LogError("SetExpressViewAcceptedSize:" + float.Parse(Screen.width.ToString()) / 600 * 90); //Debug.LogError("SetExpressViewAcceptedSize:" + float.Parse(Screen.width.ToString()) / 600 * 90);
this.AdNative.LoadExpressBannerAd(adSlot, new BannerAdListener(callback)); this.AdNative.LoadExpressBannerAd(adSlot, new BannerAdListener(callback));
} }
public void ShowCacheBannerAd() public void ShowCacheBannerAd(AdEntity entity,Action<bool> callback)
{ {
#if UNITY_IOS #if UNITY_IOS
if (bannerAdCacheListIOS.Count > 0) if (bannerAdCacheListIOS.Count > 0)
...@@ -86,7 +87,7 @@ public class CSJBannerUtil ...@@ -86,7 +87,7 @@ public class CSJBannerUtil
//{ //{
// y = 100; // 防止Demo里刘海遮挡 // y = 100; // 防止Demo里刘海遮挡
//} //}
mBanneAd.SetExpressInteractionListener(new ExpressAdInteractionListener(this, entity, callback, 1));
mBanneAd.ShowExpressAd(x, y); mBanneAd.ShowExpressAd(x, y);
} }
else else
...@@ -100,12 +101,14 @@ public class CSJBannerUtil ...@@ -100,12 +101,14 @@ public class CSJBannerUtil
//设置轮播间隔 30s--120s;不设置则不开启轮播 //设置轮播间隔 30s--120s;不设置则不开启轮播
mBanneAd.SetSlideIntervalTime(30 * 1000); mBanneAd.SetSlideIntervalTime(30 * 1000);
ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, 1); ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this,entity,callback,1);
ExpressAdDislikeCallback dislikeCallback = new ExpressAdDislikeCallback(this, 1); ExpressAdDislikeCallback dislikeCallback = new ExpressAdDislikeCallback(this, 1);
NativeAdManager.Instance().ShowExpressBannerAd(GetActivity(), mBanneAd.handle, expressAdInteractionListener, dislikeCallback); NativeAdManager.Instance().ShowExpressBannerAd(GetActivity(), mBanneAd.handle, expressAdInteractionListener, dislikeCallback);
} }
else else
{ {
callback(false);
Debug.Log("CSJ Banner广告没有缓存数据了"); Debug.Log("CSJ Banner广告没有缓存数据了");
} }
...@@ -159,11 +162,15 @@ public class CSJBannerUtil ...@@ -159,11 +162,15 @@ public class CSJBannerUtil
private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener
{ {
private CSJBannerUtil example; private CSJBannerUtil example;
private AdEntity entity;
private Action<bool> callback;
int type;//0:feed 1:banner 2:interstitial int type;//0:feed 1:banner 2:interstitial
public ExpressAdInteractionListener(CSJBannerUtil example, int type) public ExpressAdInteractionListener(CSJBannerUtil example, AdEntity entity,Action<bool> callback, int type)
{ {
this.example = example; this.example = example;
this.entity = entity;
this.callback = callback;
this.type = type; this.type = type;
} }
public void OnAdClicked(ExpressAd ad) public void OnAdClicked(ExpressAd ad)
...@@ -173,11 +180,13 @@ public class CSJBannerUtil ...@@ -173,11 +180,13 @@ public class CSJBannerUtil
public void OnAdShow(ExpressAd ad) public void OnAdShow(ExpressAd ad)
{ {
callback(true);
Debug.Log("express OnAdShow,type:" + type); Debug.Log("express OnAdShow,type:" + type);
} }
public void OnAdViewRenderError(ExpressAd ad, int code, string message) public void OnAdViewRenderError(ExpressAd ad, int code, string message)
{ {
callback(false);
Debug.Log("express OnAdViewRenderError,type:" + type); Debug.Log("express OnAdViewRenderError,type:" + type);
} }
......
...@@ -53,9 +53,9 @@ public class CSJFeedUtil : MonoBehaviour ...@@ -53,9 +53,9 @@ public class CSJFeedUtil : MonoBehaviour
{ {
var adSlot = new AdSlot.Builder() var adSlot = new AdSlot.Builder()
#if UNITY_IOS #if UNITY_IOS
.SetCodeId("900546131") .SetCodeId(entity.codeId)
#else #else
.SetCodeId("901121253") .SetCodeId(entity.codeId)
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应 ////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
.SetExpressViewAcceptedSize(350, 0) .SetExpressViewAcceptedSize(350, 0)
#endif #endif
...@@ -73,7 +73,7 @@ public class CSJFeedUtil : MonoBehaviour ...@@ -73,7 +73,7 @@ public class CSJFeedUtil : MonoBehaviour
/// 展示缓存的FeedAd /// 展示缓存的FeedAd
/// </summary> /// </summary>
/// <param name="entity"></param> /// <param name="entity"></param>
public void ShowCacheFeedAd(AdEntity entity) public void ShowCacheFeedAd(AdEntity entity,Action<bool> callback)
{ {
if (feedAdCacheList.Count > 0) if (feedAdCacheList.Count > 0)
{ {
...@@ -85,15 +85,17 @@ public class CSJFeedUtil : MonoBehaviour ...@@ -85,15 +85,17 @@ public class CSJFeedUtil : MonoBehaviour
//{ //{
// y = 100; // 防止Demo里刘海遮挡 // y = 100; // 防止Demo里刘海遮挡
//} //}
feedAd.SetExpressInteractionListener(new ExpressAdInteractionListener(this, entity, callback, 0));
feedAd.ShowExpressAd(x, y); feedAd.ShowExpressAd(x, y);
#else #else
ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, 0); ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this,entity,callback, 0);
ExpressAdDislikeCallback dislikeCallback = new ExpressAdDislikeCallback(this, 0); ExpressAdDislikeCallback dislikeCallback = new ExpressAdDislikeCallback(this, 0);
NativeAdManager.Instance().ShowExpressFeedAd(GetActivity(), feedAd.handle, expressAdInteractionListener, dislikeCallback); NativeAdManager.Instance().ShowExpressFeedAd(GetActivity(), feedAd.handle, expressAdInteractionListener, dislikeCallback);
#endif #endif
} }
else else
{ {
callback(false);
Debug.Log("CSJ Feed广告没有缓存数据了"); Debug.Log("CSJ Feed广告没有缓存数据了");
} }
} }
...@@ -143,11 +145,15 @@ public class CSJFeedUtil : MonoBehaviour ...@@ -143,11 +145,15 @@ public class CSJFeedUtil : MonoBehaviour
private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener
{ {
private CSJFeedUtil example; private CSJFeedUtil example;
private AdEntity entity;
private Action<bool> callback;
int type;//0:feed 1:banner 2:interstitial int type;//0:feed 1:banner 2:interstitial
public ExpressAdInteractionListener(CSJFeedUtil example, int type) public ExpressAdInteractionListener(CSJFeedUtil example, AdEntity entity, Action<bool> callback, int type)
{ {
this.example = example; this.example = example;
this.entity = entity;
this.callback = callback;
this.type = type; this.type = type;
} }
public void OnAdClicked(ExpressAd ad) public void OnAdClicked(ExpressAd ad)
...@@ -157,11 +163,13 @@ public class CSJFeedUtil : MonoBehaviour ...@@ -157,11 +163,13 @@ public class CSJFeedUtil : MonoBehaviour
public void OnAdShow(ExpressAd ad) public void OnAdShow(ExpressAd ad)
{ {
callback(true);
Debug.Log("express OnAdShow,type:" + type); Debug.Log("express OnAdShow,type:" + type);
} }
public void OnAdViewRenderError(ExpressAd ad, int code, string message) public void OnAdViewRenderError(ExpressAd ad, int code, string message)
{ {
callback(false);
Debug.Log("express OnAdViewRenderError,type:" + type); Debug.Log("express OnAdViewRenderError,type:" + type);
} }
......
...@@ -61,10 +61,10 @@ public class CSJInterstitialUtil ...@@ -61,10 +61,10 @@ public class CSJInterstitialUtil
{ {
var adSlot = new AdSlot.Builder() var adSlot = new AdSlot.Builder()
#if UNITY_IOS #if UNITY_IOS
.SetCodeId("900546270") .SetCodeId(entity.codeId)
.SetExpressViewAcceptedSize(200, 300) .SetExpressViewAcceptedSize(200, 300)
#else #else
.SetCodeId("901121133") .SetCodeId(entity.codeId)
.SetExpressViewAcceptedSize(350, 0) .SetExpressViewAcceptedSize(350, 0)
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应 ////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
#endif #endif
...@@ -75,7 +75,7 @@ public class CSJInterstitialUtil ...@@ -75,7 +75,7 @@ public class CSJInterstitialUtil
this.AdNative.LoadExpressInterstitialAd(adSlot, new InterstitialAdListener(callback)); this.AdNative.LoadExpressInterstitialAd(adSlot, new InterstitialAdListener(callback));
} }
public void PlayCacheInterstitialAd(AdEntity entity) public void PlayCacheInterstitialAd(AdEntity entity,Action<bool> callback)
{ {
#if UNITY_IOS #if UNITY_IOS
if (interstitialAdCacheListIOS.Count > 0) if (interstitialAdCacheListIOS.Count > 0)
...@@ -87,10 +87,12 @@ public class CSJInterstitialUtil ...@@ -87,10 +87,12 @@ public class CSJInterstitialUtil
//{ //{
// y = 100; // 防止Demo里刘海遮挡 // y = 100; // 防止Demo里刘海遮挡
//} //}
mInterstitialAd.SetExpressInteractionListener(new ExpressAdInteractionListener(this, callback, entity, 1));
mInterstitialAd.ShowExpressAd(x, y); mInterstitialAd.ShowExpressAd(x, y);
} }
else else
{ {
callback(false);
Debug.Log("CSJ 插屏广告没有缓存数据了"); Debug.Log("CSJ 插屏广告没有缓存数据了");
} }
...@@ -98,11 +100,12 @@ public class CSJInterstitialUtil ...@@ -98,11 +100,12 @@ public class CSJInterstitialUtil
if (interstitialAdCacheListAndroid.Count > 0) if (interstitialAdCacheListAndroid.Count > 0)
{ {
mInterstitialAd = interstitialAdCacheListAndroid.Dequeue(); mInterstitialAd = interstitialAdCacheListAndroid.Dequeue();
ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, 1); ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, callback,entity, 1);
NativeAdManager.Instance().ShowExpressInterstitialAd(GetActivity(), mInterstitialAd.handle, expressAdInteractionListener); NativeAdManager.Instance().ShowExpressInterstitialAd(GetActivity(), mInterstitialAd.handle, expressAdInteractionListener);
} }
else else
{ {
callback(false);
Debug.Log("CSJ 插屏广告没有缓存数据了"); Debug.Log("CSJ 插屏广告没有缓存数据了");
} }
#endif #endif
...@@ -155,11 +158,15 @@ public class CSJInterstitialUtil ...@@ -155,11 +158,15 @@ public class CSJInterstitialUtil
private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener private sealed class ExpressAdInteractionListener : IExpressAdInteractionListener
{ {
private CSJInterstitialUtil example; private CSJInterstitialUtil example;
private Action<bool> callback;
private AdEntity entity;
int type;//0:feed 1:banner 2:interstitial int type;//0:feed 1:banner 2:interstitial
public ExpressAdInteractionListener(CSJInterstitialUtil example, int type) public ExpressAdInteractionListener(CSJInterstitialUtil example,Action<bool> callback,AdEntity entity, int type)
{ {
this.example = example; this.example = example;
this.callback = callback;
this.entity = entity;
this.type = type; this.type = type;
} }
public void OnAdClicked(ExpressAd ad) public void OnAdClicked(ExpressAd ad)
......
...@@ -48,17 +48,10 @@ public class CSJRewardUtil ...@@ -48,17 +48,10 @@ public class CSJRewardUtil
public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback) public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback)
{ {
//if (this.rewardAd != null)
//{
// Debug.Log("广告已经加载");
// return;
//}
//string iosSlotID = "945113162"; //string iosSlotID = "945113162";
string iosSlotID = entity.codeId; string iosSlotID = entity.codeId;
//string AndroidSlotID = "901121593"; //string AndroidSlotID = "901121593";
string AndroidSlotID = entity.codeId; string AndroidSlotID = entity.codeId;
var adSlot = new AdSlot.Builder() var adSlot = new AdSlot.Builder()
#if UNITY_IOS #if UNITY_IOS
.SetCodeId(iosSlotID) .SetCodeId(iosSlotID)
...@@ -69,20 +62,18 @@ public class CSJRewardUtil ...@@ -69,20 +62,18 @@ public class CSJRewardUtil
.SetImageAcceptedSize(1080, 1920) .SetImageAcceptedSize(1080, 1920)
.SetRewardName("金币") // 奖励的名称 .SetRewardName("金币") // 奖励的名称
.SetRewardAmount(3) // 奖励的数量 .SetRewardAmount(3) // 奖励的数量
.SetUserID("") // 用户id,必传参数 .SetUserID("user123") // 用户id,必传参数
.SetMediaExtra("media_extra") // 附加参数,可选 .SetMediaExtra("media_extra") // 附加参数,可选
.SetOrientation(AdOrientation.Vertical) // 必填参数,期望视频的播放方向 .SetOrientation(AdOrientation.Horizontal) // 必填参数,期望视频的播放方向
.Build(); .Build();
#if UNITY_IOS #if UNITY_IOS
this.AdNative.LoadExpressRewardAd( this.AdNative.LoadExpressRewardAd(
adSlot, new RewardVideoAdListener(this,entity, callback)); adSlot, new RewardVideoAdListener(this,entity, callback));
#else #else
this.AdNative.LoadExpressRewardAd( this.AdNative.LoadRewardVideoAd(
adSlot, new RewardVideoAdListener(this, entity, callback)); adSlot, new RewardVideoAdListener(this, entity, callback));
#endif #endif
} }
/// <summary> /// <summary>
...@@ -97,7 +88,7 @@ public class CSJRewardUtil ...@@ -97,7 +88,7 @@ public class CSJRewardUtil
#if UNITY_ANDROID #if UNITY_ANDROID
RewardVideoAd rewardAd = GetRewardVideoAdForAndroid(entity.codeGroup+entity.codeId); RewardVideoAd rewardAd = GetRewardVideoAdForAndroid(entity.codeGroup+entity.codeId);
#elif UNITY_IOS #elif UNITY_IOS
ExpressRewardVideoAd rewardAd = GetRewardVideoAdForIOS(""); ExpressRewardVideoAd rewardAd = GetRewardVideoAdForIOS(entity.codeGroup+entity.codeId);
#endif #endif
if (rewardAd != null) if (rewardAd != null)
{ {
...@@ -107,7 +98,7 @@ public class CSJRewardUtil ...@@ -107,7 +98,7 @@ public class CSJRewardUtil
else else
{ {
callback(false); callback(false);
Debug.Log("CSJ 激励视频 缓存不存在"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG,"CSJ 激励视频 缓存不存在");
} }
} }
...@@ -129,14 +120,12 @@ public class CSJRewardUtil ...@@ -129,14 +120,12 @@ public class CSJRewardUtil
public void OnError(int code, string message) public void OnError(int code, string message)
{ {
Debug.Log("OnRewardError: " + message);
callback(false); callback(false);
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.adPlatform + " 激励视频 Error Group" + entity.codeGroup + " Code " + code + " msg" + message);
} }
public void OnRewardVideoAdLoad(RewardVideoAd ad) public void OnRewardVideoAdLoad(RewardVideoAd ad)
{ {
Debug.Log("OnRewardVideoAdLoad");
//ad.SetRewardAdInteractionListener( //ad.SetRewardAdInteractionListener(
// new RewardAdInteractionListener(this.csjAD)); // new RewardAdInteractionListener(this.csjAD));
//ad.SetDownloadListener( //ad.SetDownloadListener(
...@@ -151,7 +140,6 @@ public class CSJRewardUtil ...@@ -151,7 +140,6 @@ public class CSJRewardUtil
public void OnExpressRewardVideoAdLoad(ExpressRewardVideoAd ad) public void OnExpressRewardVideoAdLoad(ExpressRewardVideoAd ad)
{ {
#if UNITY_IOS #if UNITY_IOS
this.csjAD.SetRewardVideoAdForIOS(entity.codeGroup+entity.codeId, ad); this.csjAD.SetRewardVideoAdForIOS(entity.codeGroup+entity.codeId, ad);
callback(true); callback(true);
...@@ -160,7 +148,6 @@ public class CSJRewardUtil ...@@ -160,7 +148,6 @@ public class CSJRewardUtil
public void OnRewardVideoCached() public void OnRewardVideoCached()
{ {
Debug.Log("OnRewardVideoCached");
//if (this.csjAD.rewardAd != null) //if (this.csjAD.rewardAd != null)
//{ //{
// this.csjAD.rewardAd.IsDownloaded = true; // this.csjAD.rewardAd.IsDownloaded = true;
...@@ -313,7 +300,6 @@ public class CSJRewardUtil ...@@ -313,7 +300,6 @@ public class CSJRewardUtil
/// <returns></returns> /// <returns></returns>
private ExpressRewardVideoAd GetRewardVideoAdForIOS(string codeId) private ExpressRewardVideoAd GetRewardVideoAdForIOS(string codeId)
{ {
codeId = "IOS";
if (mRewardCacheMapIOS.ContainsKey(codeId)) if (mRewardCacheMapIOS.ContainsKey(codeId))
{ {
Queue<ExpressRewardVideoAd> mRewardQueue = mRewardCacheMapIOS[codeId]; Queue<ExpressRewardVideoAd> mRewardQueue = mRewardCacheMapIOS[codeId];
......
...@@ -61,8 +61,10 @@ public class CSJSplshADUtils ...@@ -61,8 +61,10 @@ public class CSJSplshADUtils
/// <param name="listener"></param> /// <param name="listener"></param>
public void LoadSplshAd(AdEntity entity,AndroidJavaObject activity, AndroidJavaObject splashAdManager, ZXADSplashListener listener, Action<bool> callback) public void LoadSplshAd(AdEntity entity,AndroidJavaObject activity, AndroidJavaObject splashAdManager, ZXADSplashListener listener, Action<bool> callback)
{ {
string iosSlotID = "800546808"; //string iosSlotID = "800546808";
string AndroidSlotID = "801121648"; //string AndroidSlotID = "801121648";
string iosSlotID = entity.codeId;
string AndroidSlotID = entity.codeId;
//// 横屏 开屏的横屏配置需要在服务端针对广告位进行设置 //// 横屏 开屏的横屏配置需要在服务端针对广告位进行设置
//if (this.getScreenOrientationConfig() == 1) //if (this.getScreenOrientationConfig() == 1)
//{ //{
......
...@@ -23,22 +23,22 @@ public final class UnionApplication extends Application { ...@@ -23,22 +23,22 @@ public final class UnionApplication extends Application {
AppliContext.init(this); AppliContext.init(this);
TTAdConfig config = new TTAdConfig.Builder() // TTAdConfig config = new TTAdConfig.Builder()
//.appId("5001121") // //.appId("5001121")
.appId("5145269") // .appId("5145269")
.useTextureView(false) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景,可以使用TextureView // .useTextureView(false) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景,可以使用TextureView
.appName("APP测试媒体") // .appName("APP测试媒体")
.titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK) // .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK)
.allowShowNotify(true) //是否允许sdk展示通知栏提示 // .allowShowNotify(true) //是否允许sdk展示通知栏提示
.allowShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页 // .allowShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页
.debug(true) //测试阶段打开,可以通过日志排查问题,上线时去除该调用 // .debug(true) //测试阶段打开,可以通过日志排查问题,上线时去除该调用
.directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI, TTAdConstant.NETWORK_STATE_3G) //允许直接下载的网络状态集合 // .directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI, TTAdConstant.NETWORK_STATE_3G) //允许直接下载的网络状态集合
.supportMultiProcess(false) //是否支持多进程,true支持 // .supportMultiProcess(false) //是否支持多进程,true支持
.customController(getController())//控制隐私数据 // .customController(getController())//控制隐私数据
.build(); // .build();
// 强烈建议在应用对应的Application#onCreate()方法中调用,避免出现content为null的异常 // // 强烈建议在应用对应的Application#onCreate()方法中调用,避免出现content为null的异常
TTAdSdk.init(this, config); // TTAdSdk.init(this, config);
//如果明确某个进程不会使用到广告SDK,可以只针对特定进程初始化广告SDK的content //如果明确某个进程不会使用到广告SDK,可以只针对特定进程初始化广告SDK的content
//if (PROCESS_NAME_XXXX.equals(processName)) { //if (PROCESS_NAME_XXXX.equals(processName)) {
...@@ -46,45 +46,45 @@ public final class UnionApplication extends Application { ...@@ -46,45 +46,45 @@ public final class UnionApplication extends Application {
//} //}
} }
private static TTCustomController getController() { // private static TTCustomController getController() {
MyTTCustomController customController = new MyTTCustomController(); // MyTTCustomController customController = new MyTTCustomController();
return customController; // return customController;
} // }
private static class MyTTCustomController extends TTCustomController{ // private static class MyTTCustomController extends TTCustomController{
@Override // @Override
public boolean isCanUseLocation() { // public boolean isCanUseLocation() {
return super.isCanUseLocation(); // return super.isCanUseLocation();
} // }
@Override // @Override
public TTLocation getTTLocation() { // public TTLocation getTTLocation() {
return super.getTTLocation(); // return super.getTTLocation();
} // }
@Override // @Override
public boolean alist() { // public boolean alist() {
return super.alist(); // return super.alist();
} // }
@Override // @Override
public boolean isCanUsePhoneState() { // public boolean isCanUsePhoneState() {
return super.isCanUsePhoneState(); // return super.isCanUsePhoneState();
} // }
@Override // @Override
public String getDevImei() { // public String getDevImei() {
return super.getDevImei(); // return super.getDevImei();
} // }
@Override // @Override
public boolean isCanUseWifiState() { // public boolean isCanUseWifiState() {
return super.isCanUseWifiState(); // return super.isCanUseWifiState();
} // }
@Override // @Override
public boolean isCanUseWriteExternal() { // public boolean isCanUseWriteExternal() {
return super.isCanUseWriteExternal(); // return super.isCanUseWriteExternal();
} // }
} // }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1508,7 +1508,7 @@ Camera: ...@@ -1508,7 +1508,7 @@ Camera:
m_Enabled: 1 m_Enabled: 1
serializedVersion: 2 serializedVersion: 2
m_ClearFlags: 1 m_ClearFlags: 1
m_BackGroundColor: {r: 0.42986825, g: 0.7849259, b: 0.8679245, a: 0} m_BackGroundColor: {r: 0.17702031, g: 0.8137047, b: 0.9622642, a: 0}
m_projectionMatrixMode: 1 m_projectionMatrixMode: 1
m_GateFitMode: 2 m_GateFitMode: 2
m_FOVAxisMode: 0 m_FOVAxisMode: 0
...@@ -2869,80 +2869,6 @@ CanvasRenderer: ...@@ -2869,80 +2869,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2017943968} m_GameObject: {fileID: 2017943968}
m_CullTransparentMesh: 0 m_CullTransparentMesh: 0
--- !u!1001 &2110713141
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2853166085728200632, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_Name
value: HTTP
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200634, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: IS_TGYZ
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2853166085728200635, guid: 1053be02c113a7a45adf322c929b0cb6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1053be02c113a7a45adf322c929b0cb6, type: 3}
--- !u!1 &2116183217 --- !u!1 &2116183217
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
<<<<<<< HEAD
AdManager.Instance.LoadCacheFSVideoAd("fullvideo");
=======
//AdManager.Instance.LoadCacheFSVideoAd();
>>>>>>> c9dc7224cab183311983fe752879dab5c389d597
}
public void OnClickPlayFullScreeVideoAd()
{
<<<<<<< HEAD
AdManager.Instance.PlayCacheFSVideoAd("fullvideo", "test", new FullScreenAdListener(this));
=======
//AdManager.Instance.PlayCacheFSVideoAd(new FullScreenAdListener(this));
>>>>>>> c9dc7224cab183311983fe752879dab5c389d597
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
<<<<<<< HEAD
AdManager.Instance.LoadCacheFSVideoAd("fullvideo");
=======
//AdManager.Instance.LoadCacheFSVideoAd();
>>>>>>> c9dc7224cab183311983fe752879dab5c389d597
}
public void OnClickPlayFullScreeVideoAd()
{
<<<<<<< HEAD
AdManager.Instance.PlayCacheFSVideoAd("fullvideo", "test", new FullScreenAdListener(this));
=======
//AdManager.Instance.PlayCacheFSVideoAd(new FullScreenAdListener(this));
>>>>>>> c9dc7224cab183311983fe752879dab5c389d597
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
AdManager.Instance.LoadCacheFSVideoAd();
}
public void OnClickPlayFullScreeVideoAd()
{
AdManager.Instance.PlayCacheFSVideoAd(new FullScreenAdListener(this));
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
AdManager.Instance.LoadCacheFSVideoAd();
}
public void OnClickPlayFullScreeVideoAd()
{
AdManager.Instance.PlayCacheFSVideoAd(new FullScreenAdListener(this));
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
AdManager.Instance.LoadCacheFSVideoAd("fullvideo");
}
public void OnClickPlayFullScreeVideoAd()
{
AdManager.Instance.PlayCacheFSVideoAd("fullvideo", "test", new FullScreenAdListener(this));
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
AdManager.Instance.LoadCacheFSVideoAd("fullvideo");
}
public void OnClickPlayFullScreeVideoAd()
{
AdManager.Instance.PlayCacheFSVideoAd("fullvideo", "test", new FullScreenAdListener(this));
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
//AdManager.Instance.LoadCacheFSVideoAd();
}
public void OnClickPlayFullScreeVideoAd()
{
//AdManager.Instance.PlayCacheFSVideoAd(new FullScreenAdListener(this));
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdDemo : MonoBehaviour
{
public Text RewardAdResult;
public void OnClickLoadRewardAd()
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void OnClickPlayRewardAd()
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(this));
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private AdDemo demo;
public RewardAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "Reward onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "Reward onAdShow";
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "Reward onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "Reward onError" + errorMsg;
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "Reward onSuccess";
}
}
public void OnClickInitAd()
{
//AdManager.Instance.LoadSplshAd(new SplshAdListener(this));
AdManager.Instance.InitAd();
}
public void OnClickPlaySplshAd()
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(this));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private AdDemo demo;
public SplshAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "开屏展示";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "开屏跳过";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "开屏错误" + errorMsg;
}
}
public void OnClickLoadBannerAd()
{
AdManager.Instance.LoadCacheBannerAd();
}
public void OnClickShowBannerAd()
{
AdManager.Instance.ShowCacheBannerAd();
}
public void OnClickLoadFeed()
{
AdManager.Instance.LoadCacheFeedAd();
}
public void OnClickShowFeed()
{
AdManager.Instance.ShowCacheFeedAd();
}
public void OnClickLoadInterAd()
{
AdManager.Instance.LoadCacheInterstitialAd();
}
public void OnClickPlayInterAd()
{
AdManager.Instance.PlayCacheInterstitialAd();
}
public void OnClickLoadFullScreeVideoAd()
{
//AdManager.Instance.LoadCacheFSVideoAd();
}
public void OnClickPlayFullScreeVideoAd()
{
//AdManager.Instance.PlayCacheFSVideoAd(new FullScreenAdListener(this));
}
private sealed class FullScreenAdListener : ZXADFullScreenVideoListener
{
private AdDemo demo;
public FullScreenAdListener(AdDemo demo)
{
this.demo = demo;
}
public void onAdClose()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdClose";
}
public void onAdShow()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdShow";
}
public void onAdSkip()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdSkip";
}
public void onAdVideoBarClick()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onAdVideoBarClick";
}
public void onError(string errorMsg)
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onError";
}
public void onSuccess()
{
this.demo.RewardAdResult.text = "FullScreenVideoAD onSuccess";
}
}
}
...@@ -28,8 +28,8 @@ public class GDTBannerAdUtil ...@@ -28,8 +28,8 @@ public class GDTBannerAdUtil
/// </summary> /// </summary>
public void LoadCacheBannerAd(AdEntity entity, Action<bool> callback) public void LoadCacheBannerAd(AdEntity entity, Action<bool> callback)
{ {
UnifiedBannerAd ad = new UnifiedBannerAd(Constants.bannerPosId, new AdSize(375, 60)); UnifiedBannerAd ad = new UnifiedBannerAd(entity.codeId, new AdSize(375, 60));
ad.SetListener(new BannerListener(ad, callback)); ad.SetListener(new BannerListener(ad, entity, callback));
ad.LoadAndShowAd(); ad.LoadAndShowAd();
} }
...@@ -38,7 +38,7 @@ public class GDTBannerAdUtil ...@@ -38,7 +38,7 @@ public class GDTBannerAdUtil
/// </summary> /// </summary>
/// <param name="entity"></param> /// <param name="entity"></param>
private UnifiedBannerAd gdtBannerAd; private UnifiedBannerAd gdtBannerAd;
public void ShowCacheBannerAd(AdEntity entity) public void ShowCacheBannerAd(AdEntity entity,Action<bool> callback)
{ {
if (bannerCacheList.Count > 0) if (bannerCacheList.Count > 0)
{ {
...@@ -47,6 +47,7 @@ public class GDTBannerAdUtil ...@@ -47,6 +47,7 @@ public class GDTBannerAdUtil
gdtBannerAd.CloseAd(); gdtBannerAd.CloseAd();
} }
gdtBannerAd = bannerCacheList.Dequeue(); gdtBannerAd = bannerCacheList.Dequeue();
gdtBannerAd.SetListener(new BannerListener(gdtBannerAd,entity,callback));
#if UNITY_ANDROID #if UNITY_ANDROID
AndroidDemoUtils.ShowView(gdtBannerAd.GetAndroidNativeView(), true); AndroidDemoUtils.ShowView(gdtBannerAd.GetAndroidNativeView(), true);
#elif UNITY_IOS #elif UNITY_IOS
...@@ -55,6 +56,7 @@ public class GDTBannerAdUtil ...@@ -55,6 +56,7 @@ public class GDTBannerAdUtil
} }
else else
{ {
callback(false);
Debug.Log("GDT Banner广告没有缓存数据了"); Debug.Log("GDT Banner广告没有缓存数据了");
} }
} }
...@@ -63,10 +65,12 @@ public class GDTBannerAdUtil ...@@ -63,10 +65,12 @@ public class GDTBannerAdUtil
/// </summary> /// </summary>
private sealed class BannerListener : IUnifiedBannerAdListener private sealed class BannerListener : IUnifiedBannerAdListener
{ {
private AdEntity entity;
private Action<bool> callback; private Action<bool> callback;
private UnifiedBannerAd bannerAD; private UnifiedBannerAd bannerAD;
public BannerListener(UnifiedBannerAd bannerAD, Action<bool> callback) public BannerListener(UnifiedBannerAd bannerAD, AdEntity entity,Action<bool> callback)
{ {
this.entity = entity;
this.bannerAD = bannerAD; this.bannerAD = bannerAD;
this.callback = callback; this.callback = callback;
} }
...@@ -97,6 +101,7 @@ public class GDTBannerAdUtil ...@@ -97,6 +101,7 @@ public class GDTBannerAdUtil
/// </summary> /// </summary>
public void OnAdExposured() public void OnAdExposured()
{ {
callback(true);
string msg = "OnAdExposured"; string msg = "OnAdExposured";
Debug.unityLogger.Log(Constants.tagForLog, msg); Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
......
...@@ -37,10 +37,10 @@ public class GDTFeedAdUtil ...@@ -37,10 +37,10 @@ public class GDTFeedAdUtil
public void LoadCacheFeedAd(AdEntity entity, Action<bool> callback) public void LoadCacheFeedAd(AdEntity entity, Action<bool> callback)
{ {
//string PosId = Constants.nativeExpressPosId;//不带视频的大图广告 //string PosId = Constants.nativeExpressPosId;//不带视频的大图广告
string PosId = Constants.nativeExpressVideoPosId;//带视频的大图广告 //string PosId = Constants.nativeExpressVideoPosId;//带视频的大图广告
NativeExpressAd ad = new NativeExpressAd(PosId, GetAdSize()); NativeExpressAd ad = new NativeExpressAd(entity.codeId, GetAdSize());
ad.SetListener(new FeedAdListener(callback)); ad.SetListener(new FeedAdListener(entity,callback));
ad.LoadAd(1); ad.LoadAd(1);
} }
...@@ -48,7 +48,7 @@ public class GDTFeedAdUtil ...@@ -48,7 +48,7 @@ public class GDTFeedAdUtil
/// 展示缓存的FeedAd /// 展示缓存的FeedAd
/// </summary> /// </summary>
/// <param name="entity"></param> /// <param name="entity"></param>
public void ShowCacheFeedAd(AdEntity entity) public void ShowCacheFeedAd(AdEntity entity,Action<bool> callback)
{ {
if (feedAd != null) if (feedAd != null)
{ {
...@@ -57,7 +57,6 @@ public class GDTFeedAdUtil ...@@ -57,7 +57,6 @@ public class GDTFeedAdUtil
if (feedAdCacheList.Count > 0) if (feedAdCacheList.Count > 0)
{ {
feedAd = feedAdCacheList.Dequeue(); feedAd = feedAdCacheList.Dequeue();
#if UNITY_IOS #if UNITY_IOS
// iOS 广告加载完毕即可展示 // iOS 广告加载完毕即可展示
feedAd.Render(); feedAd.Render();
...@@ -82,6 +81,7 @@ public class GDTFeedAdUtil ...@@ -82,6 +81,7 @@ public class GDTFeedAdUtil
} }
else else
{ {
callback(false);
Debug.Log("GDT Feed广告没有缓存数据了"); Debug.Log("GDT Feed广告没有缓存数据了");
} }
...@@ -101,9 +101,11 @@ public class GDTFeedAdUtil ...@@ -101,9 +101,11 @@ public class GDTFeedAdUtil
private sealed class FeedAdListener: INativeExpressAdListener private sealed class FeedAdListener: INativeExpressAdListener
{ {
private AdEntity entity;
private Action<bool> callback; private Action<bool> callback;
public FeedAdListener(Action<bool> callback) public FeedAdListener(AdEntity entity,Action<bool> callback)
{ {
this.entity = entity;
this.callback = callback; this.callback = callback;
} }
...@@ -150,6 +152,7 @@ public class GDTFeedAdUtil ...@@ -150,6 +152,7 @@ public class GDTFeedAdUtil
/// </summary> /// </summary>
public void OnAdViewRenderSuccess(NativeExpressAdView adView) public void OnAdViewRenderSuccess(NativeExpressAdView adView)
{ {
callback(true);
string msg = "OnAdViewRenderSuccess"; string msg = "OnAdViewRenderSuccess";
Debug.unityLogger.Log(Constants.tagForLog, msg); Debug.unityLogger.Log(Constants.tagForLog, msg);
//Debug.unityLogger.Log(Constants.tagForLog, "nativeexpressad ecpmlevel=" + example.view.GetECPMLevel()); //Debug.unityLogger.Log(Constants.tagForLog, "nativeexpressad ecpmlevel=" + example.view.GetECPMLevel());
...@@ -160,6 +163,7 @@ public class GDTFeedAdUtil ...@@ -160,6 +163,7 @@ public class GDTFeedAdUtil
/// </summary> /// </summary>
public void OnAdViewRenderFailed(NativeExpressAdView adView) public void OnAdViewRenderFailed(NativeExpressAdView adView)
{ {
callback(false);
string msg = "OnAdViewRenderFailed"; string msg = "OnAdViewRenderFailed";
Debug.unityLogger.Log(Constants.tagForLog, msg); Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
...@@ -169,6 +173,7 @@ public class GDTFeedAdUtil ...@@ -169,6 +173,7 @@ public class GDTFeedAdUtil
/// </summary> /// </summary>
public void OnAdExposured(NativeExpressAdView adView) public void OnAdExposured(NativeExpressAdView adView)
{ {
callback(true);
string msg = "OnAdExposured"; string msg = "OnAdExposured";
Debug.unityLogger.Log(Constants.tagForLog, msg); Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
...@@ -299,6 +304,7 @@ public class GDTFeedAdUtil ...@@ -299,6 +304,7 @@ public class GDTFeedAdUtil
/// </summary> /// </summary>
public void OnVideoError(NativeExpressAdView adView, AdError error) public void OnVideoError(NativeExpressAdView adView, AdError error)
{ {
callback(false);
string msg = "OnVideoError" + error.GetErrorMsg(); string msg = "OnVideoError" + error.GetErrorMsg();
Debug.unityLogger.Log(Constants.tagForLog, msg); Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
......
...@@ -96,8 +96,6 @@ public class GDTFullScreenAdUtil ...@@ -96,8 +96,6 @@ public class GDTFullScreenAdUtil
callback(true); callback(true);
example.SetFSVideoAd(entity.codeGroup+entity.codeId, ad); example.SetFSVideoAd(entity.codeGroup+entity.codeId, ad);
} }
string msg = "OnAdLoaded";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -114,8 +112,7 @@ public class GDTFullScreenAdUtil ...@@ -114,8 +112,7 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnAdShown() public void OnAdShown()
{ {
string msg = "OnAdShown";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -127,8 +124,6 @@ public class GDTFullScreenAdUtil ...@@ -127,8 +124,6 @@ public class GDTFullScreenAdUtil
{ {
listener.onAdShow(); listener.onAdShow();
} }
string msg = "OnAdExposured";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -140,8 +135,6 @@ public class GDTFullScreenAdUtil ...@@ -140,8 +135,6 @@ public class GDTFullScreenAdUtil
{ {
listener.onAdVideoBarClick(); listener.onAdVideoBarClick();
} }
string msg = "OnAdClicked";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -149,8 +142,7 @@ public class GDTFullScreenAdUtil ...@@ -149,8 +142,7 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnAdLeaveApp() public void OnAdLeaveApp()
{ {
string msg = "OnAdLeaveApp";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -166,8 +158,6 @@ public class GDTFullScreenAdUtil ...@@ -166,8 +158,6 @@ public class GDTFullScreenAdUtil
} }
listener.onAdClose(); listener.onAdClose();
} }
string msg = "OnAdClosed";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
#if UNITY_ANDROID #if UNITY_ANDROID
...@@ -177,8 +167,7 @@ public class GDTFullScreenAdUtil ...@@ -177,8 +167,7 @@ public class GDTFullScreenAdUtil
public void OnVideoCached() public void OnVideoCached()
{ {
// 视频素材加载完成,在此时调用展示,视频广告不会有进度条。 // 视频素材加载完成,在此时调用展示,视频广告不会有进度条。
string msg = "OnVideoCached";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
#endif #endif
...@@ -187,8 +176,7 @@ public class GDTFullScreenAdUtil ...@@ -187,8 +176,7 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnVideoInit() public void OnVideoInit()
{ {
string msg = "OnVideoInit";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -196,8 +184,7 @@ public class GDTFullScreenAdUtil ...@@ -196,8 +184,7 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnVideoLoading() public void OnVideoLoading()
{ {
string msg = "OnVideoLoading";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -209,8 +196,6 @@ public class GDTFullScreenAdUtil ...@@ -209,8 +196,6 @@ public class GDTFullScreenAdUtil
{ {
listener.onSuccess(); listener.onSuccess();
} }
string msg = "OnVideoStarted";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -218,8 +203,6 @@ public class GDTFullScreenAdUtil ...@@ -218,8 +203,6 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnVideoPaused() public void OnVideoPaused()
{ {
string msg = "OnVideoPaused";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -229,8 +212,6 @@ public class GDTFullScreenAdUtil ...@@ -229,8 +212,6 @@ public class GDTFullScreenAdUtil
{ {
isSkipAd = false; isSkipAd = false;
string msg = "OnVideoCompleted";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -243,8 +224,6 @@ public class GDTFullScreenAdUtil ...@@ -243,8 +224,6 @@ public class GDTFullScreenAdUtil
listener.onError("GDT 全屏视频播放失败"); listener.onError("GDT 全屏视频播放失败");
} }
callback(false); callback(false);
string msg = "OnVideoError";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -252,8 +231,7 @@ public class GDTFullScreenAdUtil ...@@ -252,8 +231,7 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnVideoDetailPageShown() public void OnVideoDetailPageShown()
{ {
string msg = "OnVideoDetailPageShown";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -261,8 +239,7 @@ public class GDTFullScreenAdUtil ...@@ -261,8 +239,7 @@ public class GDTFullScreenAdUtil
/// </summary> /// </summary>
public void OnVideoDetailPageClosed() public void OnVideoDetailPageClosed()
{ {
string msg = "OnVideoDetailPageClosed";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
} }
......
...@@ -35,10 +35,10 @@ public class GDTInterstitialAdUtil ...@@ -35,10 +35,10 @@ public class GDTInterstitialAdUtil
public void LoadCacheInterstitialAd(AdEntity entity, Action<bool> callback) public void LoadCacheInterstitialAd(AdEntity entity, Action<bool> callback)
{ {
string posId = Constants.intersititialVideoPosId;//带视频插屏测试广告 //string posId = Constants.intersititialVideoPosId;//带视频插屏测试广告
//string posId = Constants.intersititialNoVideoPosId;//不带视频的插屏广告测试Id //string posId = Constants.intersititialNoVideoPosId;//不带视频的插屏广告测试Id
UnifiedInterstitialAd ad = new UnifiedInterstitialAd(posId); UnifiedInterstitialAd ad = new UnifiedInterstitialAd(entity.codeId);
ad.SetListener(new UnifiedInterstitialAdListener(ad,callback)); ad.SetListener(new UnifiedInterstitialAdListener(ad,callback));
ad.LoadAd(); ad.LoadAd();
} }
...@@ -47,15 +47,17 @@ public class GDTInterstitialAdUtil ...@@ -47,15 +47,17 @@ public class GDTInterstitialAdUtil
/// 播放缓存的插屏广告 /// 播放缓存的插屏广告
/// </summary> /// </summary>
/// <param name="entity"></param> /// <param name="entity"></param>
public void PlayCacheInterstitialAd(AdEntity entity) public void PlayCacheInterstitialAd(AdEntity entity,Action<bool> callback)
{ {
if (interstitialAdCacheList.Count > 0) if (interstitialAdCacheList.Count > 0)
{ {
UnifiedInterstitialAd interAd = interstitialAdCacheList.Dequeue(); UnifiedInterstitialAd interAd = interstitialAdCacheList.Dequeue();
interAd.SetListener(new UnifiedInterstitialAdListener(interAd, callback));
interAd.Show(); interAd.Show();
} }
else else
{ {
callback(false);
Debug.Log("GDT 插屏广告没有缓存数据了"); Debug.Log("GDT 插屏广告没有缓存数据了");
} }
} }
...@@ -82,8 +84,6 @@ public class GDTInterstitialAdUtil ...@@ -82,8 +84,6 @@ public class GDTInterstitialAdUtil
{ {
interstitialAdCacheList.Enqueue(ad); interstitialAdCacheList.Enqueue(ad);
callback(true); callback(true);
string msg = "OnAdLoaded";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -92,8 +92,6 @@ public class GDTInterstitialAdUtil ...@@ -92,8 +92,6 @@ public class GDTInterstitialAdUtil
public void OnError(AdError error) public void OnError(AdError error)
{ {
callback(false); callback(false);
string msg = "OnError" + error.GetErrorMsg();
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -101,8 +99,7 @@ public class GDTInterstitialAdUtil ...@@ -101,8 +99,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnAdShown() public void OnAdShown()
{ {
string msg = "OnAdShown";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -110,8 +107,7 @@ public class GDTInterstitialAdUtil ...@@ -110,8 +107,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnAdExposured() public void OnAdExposured()
{ {
string msg = "OnAdExposured"; callback(true);
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -119,8 +115,7 @@ public class GDTInterstitialAdUtil ...@@ -119,8 +115,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnAdClicked() public void OnAdClicked()
{ {
string msg = "OnAdClicked";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -128,8 +123,7 @@ public class GDTInterstitialAdUtil ...@@ -128,8 +123,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnAdLeaveApp() public void OnAdLeaveApp()
{ {
string msg = "OnAdLeaveApp";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -137,8 +131,7 @@ public class GDTInterstitialAdUtil ...@@ -137,8 +131,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnAdClosed() public void OnAdClosed()
{ {
string msg = "OnAdClosed";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
#if UNITY_ANDROID #if UNITY_ANDROID
...@@ -148,8 +141,7 @@ public class GDTInterstitialAdUtil ...@@ -148,8 +141,7 @@ public class GDTInterstitialAdUtil
public void OnVideoCached() public void OnVideoCached()
{ {
// 视频素材加载完成,在此时调用展示,视频广告不会有进度条。 // 视频素材加载完成,在此时调用展示,视频广告不会有进度条。
string msg = "OnVideoCached";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
#endif #endif
...@@ -158,8 +150,7 @@ public class GDTInterstitialAdUtil ...@@ -158,8 +150,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoInit() public void OnVideoInit()
{ {
string msg = "OnVideoInit";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -167,8 +158,7 @@ public class GDTInterstitialAdUtil ...@@ -167,8 +158,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoLoading() public void OnVideoLoading()
{ {
string msg = "OnVideoLoading";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -176,8 +166,7 @@ public class GDTInterstitialAdUtil ...@@ -176,8 +166,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoStarted() public void OnVideoStarted()
{ {
string msg = "OnVideoStarted";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -185,8 +174,7 @@ public class GDTInterstitialAdUtil ...@@ -185,8 +174,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoPaused() public void OnVideoPaused()
{ {
string msg = "OnVideoPaused";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -194,8 +182,7 @@ public class GDTInterstitialAdUtil ...@@ -194,8 +182,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoCompleted() public void OnVideoCompleted()
{ {
string msg = "OnVideoCompleted";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -203,8 +190,7 @@ public class GDTInterstitialAdUtil ...@@ -203,8 +190,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoError() public void OnVideoError()
{ {
string msg = "OnVideoError";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -212,8 +198,7 @@ public class GDTInterstitialAdUtil ...@@ -212,8 +198,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoDetailPageShown() public void OnVideoDetailPageShown()
{ {
string msg = "OnVideoDetailPageShown";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
/// <summary> /// <summary>
...@@ -221,8 +206,7 @@ public class GDTInterstitialAdUtil ...@@ -221,8 +206,7 @@ public class GDTInterstitialAdUtil
/// </summary> /// </summary>
public void OnVideoDetailPageClosed() public void OnVideoDetailPageClosed()
{ {
string msg = "OnVideoDetailPageClosed";
Debug.unityLogger.Log(Constants.tagForLog, msg);
} }
} }
} }
...@@ -28,9 +28,9 @@ public class GDTRewardAdUtil ...@@ -28,9 +28,9 @@ public class GDTRewardAdUtil
/// <param name="callback"></param> /// <param name="callback"></param>
public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback) public void LoadCacheRewardAd(AdEntity entity, Action<bool> callback)
{ {
RewardVideoAd rewardVideoAd = new RewardVideoAd(Constants.rewardVideoPosId); RewardVideoAd rewardVideoAd = new RewardVideoAd(entity.codeId);
rewardVideoAd.SetListener(new RewardVideoAdListener(this, entity, rewardVideoAd, callback, true)); rewardVideoAd.SetListener(new RewardVideoAdListener(this, entity, rewardVideoAd, callback, true));
rewardVideoAd.SetVideoMuted(false);//设置声音 rewardVideoAd.SetVideoMuted(true);//设置声音
rewardVideoAd.LoadAd(); rewardVideoAd.LoadAd();
} }
...@@ -50,7 +50,7 @@ public class GDTRewardAdUtil ...@@ -50,7 +50,7 @@ public class GDTRewardAdUtil
#if UNITY_IOS #if UNITY_IOS
rewardAd.SetEnableDefaultAudioSessionSetting(false); rewardAd.SetEnableDefaultAudioSessionSetting(false);
#endif #endif
rewardAd.SetVideoMuted(false);//设置是否打开声音 rewardAd.SetVideoMuted(true);//设置是否打开声音
rewardAd.ShowAD(); rewardAd.ShowAD();
} }
else else
...@@ -128,11 +128,13 @@ public class GDTRewardAdUtil ...@@ -128,11 +128,13 @@ public class GDTRewardAdUtil
public void OnError(AdError error) public void OnError(AdError error)
{ {
if (listener != null) if (listener != null)
{ {
listener.onError("GDT RewardVideo ErrorCode" + error.GetErrorCode() + " Msg:" + error.GetErrorMsg()); listener.onError("GDT RewardVideo ErrorCode" + error.GetErrorCode() + " Msg:" + error.GetErrorMsg());
} }
callback(false); callback(false);
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.adPlatform + " 激励视频 Error Group" + entity.codeGroup + " Code " + error.GetErrorCode() + " msg" + error.GetErrorMsg());
} }
public void OnRewarded() public void OnRewarded()
......
...@@ -9,6 +9,7 @@ PluginImporter: ...@@ -9,6 +9,7 @@ PluginImporter:
isPreloaded: 0 isPreloaded: 0
isOverridable: 0 isOverridable: 0
isExplicitlyReferenced: 0 isExplicitlyReferenced: 0
validateReferences: 1
platformData: platformData:
- first: - first:
Android: Android Android: Android
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: ea5489225a2e4482096765b124c62e25 guid: cbfc243b533794f4a9a553e3e085f2be
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
...@@ -16,6 +16,8 @@ public class Splash : MonoBehaviour ...@@ -16,6 +16,8 @@ public class Splash : MonoBehaviour
/// </summary> /// </summary>
private void Awake() private void Awake()
{ {
//Application.runInBackground = true;
} }
...@@ -46,6 +48,7 @@ public class Splash : MonoBehaviour ...@@ -46,6 +48,7 @@ public class Splash : MonoBehaviour
{ {
yield return new WaitForSeconds(3f); yield return new WaitForSeconds(3f);
AdManager.Instance.LoadSplashAd(new SplshAdListener()); AdManager.Instance.LoadSplashAd(new SplshAdListener());
AdManager.Instance.LoadCacheRewardVideoAd("video");
} }
private sealed class SplshAdListener : ZXADSplashListener private sealed class SplshAdListener : ZXADSplashListener
...@@ -61,6 +64,7 @@ public class Splash : MonoBehaviour ...@@ -61,6 +64,7 @@ public class Splash : MonoBehaviour
public void onError(string errorMsg) public void onError(string errorMsg)
{ {
SceneManager.LoadScene("AdDemo");
} }
} }
......
fileFormatVersion: 2
guid: ddf78793cf99f4b699c5a9dcf9cc2b60
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.Android; using UnityEngine.Android;
using UnityEngine.UI; using UnityEngine.UI;
...@@ -36,7 +35,7 @@ public class HttpTest : MonoBehaviour ...@@ -36,7 +35,7 @@ public class HttpTest : MonoBehaviour
public void OnClickPost() public void OnClickPost()
{ {
Dictionary<string, string> d = new Dictionary<string, string>(); Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("type", "1"); d.Add("type", "1");
//HttpTool.Instance._Post("app/v1/game/xynt/use_fertilize", "", null, actionRes); //HttpTool.Instance._Post("app/v1/game/xynt/use_fertilize", "", null, actionRes);
HttpTool.Instance._Post("app/v1/game/xynt/box_reward", d, new Action<TestBean>((bean) => HttpTool.Instance._Post("app/v1/game/xynt/box_reward", d, new Action<TestBean>((bean) =>
...@@ -80,7 +79,7 @@ public class HttpTest : MonoBehaviour ...@@ -80,7 +79,7 @@ public class HttpTest : MonoBehaviour
AndroidJavaClass cpuUtils = new AndroidJavaClass( AndroidJavaClass cpuUtils = new AndroidJavaClass(
"com.unity.adcommon.unity.CpuUtils"); "com.unity.adcommon.unity.CpuUtils");
Dictionary<string, string> d = new Dictionary<string, string>(); Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("md5", PrefenceUtils.GetInstance().getMd5()); d.Add("md5", PrefenceUtils.GetInstance().getMd5());
d.Add("type", cpuUtils.CallStatic<string>("getArchType")); d.Add("type", cpuUtils.CallStatic<string>("getArchType"));
HttpTool.Instance._Get("app/v1/novel/info", d, new Action<TestBean>((bean) => HttpTool.Instance._Get("app/v1/novel/info", d, new Action<TestBean>((bean) =>
......
...@@ -6,7 +6,9 @@ using System; ...@@ -6,7 +6,9 @@ using System;
using System.Text; using System.Text;
using System.Linq; using System.Linq;
using LitJson; using LitJson;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
public delegate void HttpResponse(string result); public delegate void HttpResponse(string result);
...@@ -19,7 +21,7 @@ public class HttpTool : MonoBehaviour ...@@ -19,7 +21,7 @@ public class HttpTool : MonoBehaviour
private static HttpTool _instacne = null; private static HttpTool _instacne = null;
private string TEST_BASE_URL = "http://feedapitest3.zhangxinhulian.com/";//测试 private string TEST_BASE_URL = "http://feedapitest.zhangxinhulian.com/";//测试
private string TEST_AD_BASE_URL = "https://bstest.zhangxinhulian.com/";//测试 private string TEST_AD_BASE_URL = "https://bstest.zhangxinhulian.com/";//测试
private string PRODUCT_BASE_URL = "https://feedapi.zhangxinhulian.com/";//正式 private string PRODUCT_BASE_URL = "https://feedapi.zhangxinhulian.com/";//正式
...@@ -29,9 +31,7 @@ public class HttpTool : MonoBehaviour ...@@ -29,9 +31,7 @@ public class HttpTool : MonoBehaviour
private int timeOut = 10;//超时时间 private int timeOut = 10;//超时时间
Dictionary<string, object> requestHeader = new Dictionary<string, object>(); // header
Dictionary<string, string> requestHeader = new Dictionary<string, string>(); // header
public static HttpTool Instance public static HttpTool Instance
{ {
get get
...@@ -48,7 +48,7 @@ public class HttpTool : MonoBehaviour ...@@ -48,7 +48,7 @@ public class HttpTool : MonoBehaviour
{ {
if (IS_TEST) if (IS_TEST)
{ {
baseUrl = TEST_AD_BASE_URL; baseUrl = TEST_BASE_URL;
} }
else else
{ {
...@@ -62,22 +62,76 @@ public class HttpTool : MonoBehaviour ...@@ -62,22 +62,76 @@ public class HttpTool : MonoBehaviour
requestHeader.Add("Content-Type", "application/json"); requestHeader.Add("Content-Type", "application/json");
} }
public void _Get<T>(string methodName, Dictionary<string, string> getParas,Action<T> success, Action<string,string> failed) public void _GetAD<T>(string methodName, Dictionary<string, object> getParas, Action<T> success, Action<string, string> failed)
{
string AdUrl;
if (IS_TEST)
{
AdUrl = TEST_AD_BASE_URL;
}
else
{
AdUrl = PRODUCT_BASE_URL;
}
var handler = new HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.GZip
};
try
{
using (var http = new HttpClient(handler))
{
using (HttpContent content = new StringContent(""))
{
//content.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=UTF-8");
var response = http.GetAsync(AdUrl + methodName + "?" + addParams(getParas)).Result; // postParaStr 注意拼接好
string rsult = response.Content.ReadAsStringAsync().Result;
if (response.IsSuccessStatusCode)
{
RequestResult(rsult, success, failed);
}
else
{
if (failed != null)
{
failed("0", rsult);
}
}
}
};
}
catch (Exception ex)
{
if (failed != null)
{
failed("-1", ex.Message);
}
}
}
public void _Get<T>(string methodName, Dictionary<string, object> getParas, Action<T> success, Action<string, string> failed)
{ {
StartCoroutine(GetRequest(methodName, getParas, success,failed)); StartCoroutine(GetRequest(baseUrl,methodName, getParas, success, failed));
} }
public IEnumerator GetRequest<T>(string methodName, Dictionary<string, string> getParas, Action<T> success, Action<string, string> failed) public IEnumerator GetRequest<T>(string BaseURL,string methodName, Dictionary<string, object> getParas, Action<T> success, Action<string, string> failed)
{ {
string url = baseUrl + methodName + "?" + addParams(getParas); string url = BaseURL + methodName + "?" + addParams(getParas);
Debug.unityLogger.Log(HttpLogTag, "GET RequestUrl=> " + url); Debug.unityLogger.Log(HttpLogTag, "GET RequestUrl=> " + url);
using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
{ {
//设置header //设置header
foreach (var v in requestHeader) foreach (var v in requestHeader)
{ {
webRequest.SetRequestHeader(v.Key, v.Value); webRequest.SetRequestHeader(v.Key, (string)v.Value);
} }
webRequest.timeout = timeOut; webRequest.timeout = timeOut;
yield return webRequest.SendWebRequest(); yield return webRequest.SendWebRequest();
...@@ -99,13 +153,13 @@ public class HttpTool : MonoBehaviour ...@@ -99,13 +153,13 @@ public class HttpTool : MonoBehaviour
} }
//jsonString 为json字符串,post提交的数据包为json //jsonString 为json字符串,post提交的数据包为json
public void _Post<T>(string methodName, Dictionary<string, string> postParas, Action<T> success, Action<string, string> failed) public void _Post<T>(string methodName, Dictionary<string, object> postParas, Action<T> success, Action<string, string> failed)
{ {
StartCoroutine(PostRequest(methodName, "", postParas, success,failed)); StartCoroutine(PostRequest(baseUrl, methodName, "", postParas, success, failed));
} }
public IEnumerator PostRequest<T>(string methodName, string jsonString, Dictionary<string, string> postParas, Action<T> success, Action<string, string> failed) public IEnumerator PostRequest<T>(string BaseURL,string methodName, string jsonString, Dictionary<string, object> postParas, Action<T> success, Action<string, string> failed)
{ {
string url = baseUrl + methodName +"?" + addParams(postParas); string url = BaseURL + methodName + "?" + addParams(postParas);
Debug.unityLogger.Log(HttpLogTag, "POST RequestUrl=> " + url); Debug.unityLogger.Log(HttpLogTag, "POST RequestUrl=> " + url);
//Debug.Log("POST 请求 :url: \n" + url); //Debug.Log("POST 请求 :url: \n" + url);
//Debug.Log(string.Format("url:{0} postData:{1}", url, jsonString)); //Debug.Log(string.Format("url:{0} postData:{1}", url, jsonString));
...@@ -122,7 +176,7 @@ public class HttpTool : MonoBehaviour ...@@ -122,7 +176,7 @@ public class HttpTool : MonoBehaviour
foreach (var v in requestHeader) foreach (var v in requestHeader)
{ {
webRequest.SetRequestHeader(v.Key, v.Value); webRequest.SetRequestHeader(v.Key, (string)v.Value);
} }
webRequest.timeout = timeOut; webRequest.timeout = timeOut;
yield return webRequest.SendWebRequest(); yield return webRequest.SendWebRequest();
...@@ -143,7 +197,7 @@ public class HttpTool : MonoBehaviour ...@@ -143,7 +197,7 @@ public class HttpTool : MonoBehaviour
} }
private void RequestResult<T>(string json,Action<T> success, Action<string, string> failed) private void RequestResult<T>(string json, Action<T> success, Action<string, string> failed)
{ {
Debug.unityLogger.Log(HttpLogTag, "Json=> " + json); Debug.unityLogger.Log(HttpLogTag, "Json=> " + json);
if (success != null) if (success != null)
...@@ -167,7 +221,7 @@ public class HttpTool : MonoBehaviour ...@@ -167,7 +221,7 @@ public class HttpTool : MonoBehaviour
{ {
if (failed != null) if (failed != null)
{ {
failed("", e.Message); failed("-2", e.Message);
} }
} }
...@@ -175,20 +229,20 @@ public class HttpTool : MonoBehaviour ...@@ -175,20 +229,20 @@ public class HttpTool : MonoBehaviour
} }
public string appLs= "1d8a0d53c33a9b95"; public string appLs = "1d8a0d53c33a9b95";
public string appkey = "faba1d018f76086"; public string appkey = "faba1d018f76086";
private string addParams(Dictionary<string, string> request) private string addParams(Dictionary<string, object> request)
{ {
if (request == null) if (request == null)
{ {
request = new Dictionary<string, string>(); request = new Dictionary<string, object>();
} }
string strTemp = string.Empty; string strTemp = string.Empty;
//定义 //定义
Dictionary<string, string> paragrams = request; Dictionary<string, object> paragrams = request;
if (IS_TGYZ) if (IS_TEST)
{ {
paragrams.Add("zygt", "hzwz"); paragrams.Add("zygt", "hzwz");
paragrams.Add("tgtk", "1"); paragrams.Add("tgtk", "1");
...@@ -202,7 +256,7 @@ public class HttpTool : MonoBehaviour ...@@ -202,7 +256,7 @@ public class HttpTool : MonoBehaviour
paragrams.Add("token", PrefenceUtils.GetInstance().getToken()); paragrams.Add("token", PrefenceUtils.GetInstance().getToken());
paragrams.Add("appLs", appLs); paragrams.Add("appLs", appLs);
paragrams.Add("appKey",appkey); paragrams.Add("appKey", appkey);
paragrams.Add("city", ""); paragrams.Add("city", "");
paragrams.Add("lon", ""); paragrams.Add("lon", "");
...@@ -224,7 +278,7 @@ public class HttpTool : MonoBehaviour ...@@ -224,7 +278,7 @@ public class HttpTool : MonoBehaviour
paragrams.Add("ntt", PrefenceUtils.GetInstance().getNTT()); paragrams.Add("ntt", PrefenceUtils.GetInstance().getNTT());
paragrams.Add("carrier", PrefenceUtils.GetInstance().getCarrier()); paragrams.Add("carrier", PrefenceUtils.GetInstance().getCarrier());
paragrams.Add("w", ""+Screen.width); paragrams.Add("w", "" + Screen.width);
paragrams.Add("vn", PrefenceUtils.GetInstance().getVN()); paragrams.Add("vn", PrefenceUtils.GetInstance().getVN());
paragrams.Add("imei", PrefenceUtils.GetInstance().getImei()); paragrams.Add("imei", PrefenceUtils.GetInstance().getImei());
#if UNITY_ANDROID #if UNITY_ANDROID
...@@ -233,7 +287,7 @@ public class HttpTool : MonoBehaviour ...@@ -233,7 +287,7 @@ public class HttpTool : MonoBehaviour
paragrams.Add("aid", SystemInfo.deviceUniqueIdentifier);//TODO 有bug paragrams.Add("aid", SystemInfo.deviceUniqueIdentifier);//TODO 有bug
#endif #endif
paragrams.Add("device", PrefenceUtils.GetInstance().getDevice()); paragrams.Add("device", PrefenceUtils.GetInstance().getDevice());
paragrams.Add("ts", ""+(DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000); paragrams.Add("ts", "" + (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000);
#if UNITY_IOS #if UNITY_IOS
paragrams.Add("platform", "ios"); paragrams.Add("platform", "ios");
paragrams.Add("source", "AppStore"); paragrams.Add("source", "AppStore");
...@@ -245,10 +299,10 @@ public class HttpTool : MonoBehaviour ...@@ -245,10 +299,10 @@ public class HttpTool : MonoBehaviour
#endif #endif
string signString = signParamsWithDict(paragrams); string signString = signParamsWithDict(paragrams);
paragrams.Add("sign", signString); paragrams.Add("sign", signString);
foreach (KeyValuePair<string, string> item in paragrams) foreach (KeyValuePair<string, object> item in paragrams)
{ {
// && !string.IsNullOrEmpty(item.Value) // && !string.IsNullOrEmpty(item.Value)
if (!string.IsNullOrEmpty(item.Key) && !string.IsNullOrEmpty(item.Value)) if (!string.IsNullOrEmpty(item.Key) && !string.IsNullOrEmpty(Convert.ToString(item.Value)))
{ {
strTemp += item.Key + "=" + item.Value + "&"; strTemp += item.Key + "=" + item.Value + "&";
} }
...@@ -265,14 +319,14 @@ public class HttpTool : MonoBehaviour ...@@ -265,14 +319,14 @@ public class HttpTool : MonoBehaviour
/// </summary> /// </summary>
/// <param name="dict"></param> /// <param name="dict"></param>
/// <returns></returns> /// <returns></returns>
public string signParamsWithDict(Dictionary<string, string> dict) public string signParamsWithDict(Dictionary<string, object> dict)
{ {
// 通过key 排序 // 通过key 排序
Dictionary<string, string> dic1_SortedByKey = dict.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value); Dictionary<string, object> dic1_SortedByKey = dict.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value);
string mutaSting = ""; string mutaSting = "";
//遍历字典 //遍历字典
foreach (KeyValuePair<string, string> kvp in dic1_SortedByKey) foreach (KeyValuePair<string, object> kvp in dic1_SortedByKey)
{ {
//Debug.Log(kvp.Key + ":" + kvp.Value); //Debug.Log(kvp.Key + ":" + kvp.Value);
mutaSting += kvp.Value; mutaSting += kvp.Value;
...@@ -325,70 +379,29 @@ public class HttpTool : MonoBehaviour ...@@ -325,70 +379,29 @@ public class HttpTool : MonoBehaviour
return imei0; return imei0;
//texts[18].text = "IMEI1:" + imei1; //texts[18].text = "IMEI1:" + imei1;
//texts[19].text = "MEID:" + meid; //texts[19].text = "MEID:" + meid;
}catch (Exception e) }
catch (Exception e)
{ {
return ""; return "";
} }
} }
#endregion #endregion
public void TestPost<T>(string url, Dictionary<string, string> postParas, Action<BaseBean<T>> success,Action<ErrorBean> action1)
{
StartCoroutine(GetRequest<T>(url, postParas, success, action1));
}
public IEnumerator GetRequest<T>(string methodName, Dictionary<string, string> getParas, Action<BaseBean<T>> t,Action<ErrorBean> error)
{
string url = baseUrl + methodName + "?" + addParams(getParas);
//string url = baseUrl + methodName; void OnApplicationPause(bool paused)
Debug.Log("GET 请求 :url: \n" + url);
using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
{
//设置header
foreach (var v in requestHeader)
{ {
webRequest.SetRequestHeader(v.Key, v.Value); Debug.unityLogger.Log("TIME_SCALE",paused+"当前速率" + Time.timeScale);
} if (paused)
webRequest.timeout = timeOut;
yield return webRequest.SendWebRequest();
string result;
if (webRequest.isHttpError || webRequest.isNetworkError)
{ {
Debug.LogError(webRequest.error + "\n" + webRequest.downloadHandler.text); //程序进入后台时执行
result = webRequest.error; ; Debug.unityLogger.Log("当前速率" + Time.timeScale);
//Time.timeScale = 1;
//TODO error
} }
else else
{ {
result = webRequest.downloadHandler.text; //程序从后台进入前台时
BaseBean<T> baseBean = JsonUtility.FromJson<BaseBean<T>>(result);
switch (baseBean.status)
{
case 200:
break;
case 105:
break;
default:
break;
} }
} }
}
}
} }
...@@ -12,12 +12,12 @@ EditorBuildSettings: ...@@ -12,12 +12,12 @@ EditorBuildSettings:
path: Assets/AD/GDT/UnionDemo/UnionExample.unity path: Assets/AD/GDT/UnionDemo/UnionExample.unity
guid: 6c963ae210fa3c3438c2f6770ee81fc9 guid: 6c963ae210fa3c3438c2f6770ee81fc9
- enabled: 1 - enabled: 1
path: Assets/Splash/Splash.unity path: Assets/Game/Splash/Splash.unity
guid: 37af8cf3fb373478ab04e3ee2f3b700a guid: 37af8cf3fb373478ab04e3ee2f3b700a
- enabled: 1 - enabled: 1
path: Assets/AD/Demo/AdDemo.unity path: Assets/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2 guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 1 - enabled: 0
path: Assets/NetWork/Demo/HttpDemo.unity path: Assets/NetWork/Demo/HttpDemo.unity
guid: 1d254830c8b62484bb74d303cbb2cc3d guid: 1d254830c8b62484bb74d303cbb2cc3d
m_configObjects: {} m_configObjects: {}
...@@ -262,15 +262,15 @@ PlayerSettings: ...@@ -262,15 +262,15 @@ PlayerSettings:
AndroidTargetArchitectures: 1 AndroidTargetArchitectures: 1
AndroidSplashScreenScale: 0 AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0} androidSplashScreen: {fileID: 0}
AndroidKeystoreName: AndroidKeystoreName: D:/antearn.jks
AndroidKeyaliasName: AndroidKeyaliasName: antearn
AndroidBuildApkPerCpuArchitecture: 0 AndroidBuildApkPerCpuArchitecture: 0
AndroidTVCompatibility: 0 AndroidTVCompatibility: 0
AndroidIsGame: 1 AndroidIsGame: 1
AndroidEnableTango: 0 AndroidEnableTango: 0
androidEnableBanner: 1 androidEnableBanner: 1
androidUseLowAccuracyLocation: 0 androidUseLowAccuracyLocation: 0
androidUseCustomKeystore: 0 androidUseCustomKeystore: 1
m_AndroidBanners: m_AndroidBanners:
- width: 320 - width: 320
height: 180 height: 180
...@@ -654,7 +654,8 @@ PlayerSettings: ...@@ -654,7 +654,8 @@ PlayerSettings:
webGLWasmStreaming: 0 webGLWasmStreaming: 0
scriptingDefineSymbols: {} scriptingDefineSymbols: {}
platformArchitecture: {} platformArchitecture: {}
scriptingBackend: {} scriptingBackend:
Android: 0
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration: {}
managedStrippingLevel: {} managedStrippingLevel: {}
incrementalIl2cppBuild: {} incrementalIl2cppBuild: {}
...@@ -664,7 +665,8 @@ PlayerSettings: ...@@ -664,7 +665,8 @@ PlayerSettings:
gcIncremental: 1 gcIncremental: 1
assemblyVersionValidation: 1 assemblyVersionValidation: 1
gcWBarrierValidation: 0 gcWBarrierValidation: 0
apiCompatibilityLevelPerPlatform: {} apiCompatibilityLevelPerPlatform:
Android: 6
m_RenderingPath: 1 m_RenderingPath: 1
m_MobileRenderingPath: 1 m_MobileRenderingPath: 1
metroPackageName: 2D_BuiltInRenderer metroPackageName: 2D_BuiltInRenderer
......
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