Commit 4b21d563 authored by 王雪伟's avatar 王雪伟

1.3.8

parent 643c3b87
...@@ -63,7 +63,7 @@ public class AdHttpUtil : MonoBehaviour ...@@ -63,7 +63,7 @@ public class AdHttpUtil : MonoBehaviour
private IEnumerator GetRequest<T>(string BaseURL, string methodName, Dictionary<string, object> getParas, Action<T> success, Action<string, string> failed) private IEnumerator GetRequest<T>(string BaseURL, string methodName, Dictionary<string, object> getParas, Action<T> success, Action<string, string> failed)
{ {
string url = BaseURL + methodName + "?" + HttpUtil.addParams(getParas); string url = BaseURL + methodName + "?" + "priceSort=true&" + HttpUtil.addParams(getParas);
using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
{ {
//设置header //设置header
......
...@@ -1419,6 +1419,10 @@ public class AdManager ...@@ -1419,6 +1419,10 @@ public class AdManager
//快手激励视频广告加载 //快手激励视频广告加载
KsRewardVideoAdUtils.Instance.LoadCacheRewardAd(entity, callback); KsRewardVideoAdUtils.Instance.LoadCacheRewardAd(entity, callback);
break; break;
case ZXADConfig.PLANTFORM_AD_ZXHC:
//掌心汇川激励视频广告加载
ZXHCRewardAdUtil.Instance.LoadCacheRewardAd(entity, callback);
break;
#endif #endif
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持加载" + entity.adPlatform + "的激励视频广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持加载" + entity.adPlatform + "的激励视频广告");
...@@ -1539,6 +1543,10 @@ public class AdManager ...@@ -1539,6 +1543,10 @@ public class AdManager
//快手激励视频广告播放 //快手激励视频广告播放
KsRewardVideoAdUtils.Instance.playCacheRewardAd(entity, listener, callback); KsRewardVideoAdUtils.Instance.playCacheRewardAd(entity, listener, callback);
break; break;
case ZXADConfig.PLANTFORM_AD_ZXHC:
//掌心汇川激励视频广告播放
ZXHCRewardAdUtil.Instance.playCacheRewardAd(entity, listener, callback);
break;
#endif #endif
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持Show" + entity.adPlatform + "的激励视频广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持Show" + entity.adPlatform + "的激励视频广告");
......
...@@ -14,8 +14,8 @@ public class ZXADConfig ...@@ -14,8 +14,8 @@ public class ZXADConfig
} }
} }
public const int ZXAD_VC = 137; public const int ZXAD_VC = 138;
public const string ZXAD_VN = "1.3.7"; public const string ZXAD_VN = "1.3.8";
public const string ADManagerTAG = "AdManager"; public const string ADManagerTAG = "AdManager";
public const string PLANTFORM_AD_TT = "chuanshanjia"; //穿山甲 public const string PLANTFORM_AD_TT = "chuanshanjia"; //穿山甲
......
...@@ -9,7 +9,7 @@ namespace ZXHC ...@@ -9,7 +9,7 @@ namespace ZXHC
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
ZXHCADManager.Init("1000127",true); ZXHCADManager.Init("1000127",false);
} }
// Update is called once per frame // Update is called once per frame
...@@ -82,6 +82,65 @@ namespace ZXHC ...@@ -82,6 +82,65 @@ namespace ZXHC
} }
public void OnClickLoadRewardAd()
{
AdEntity entity = new AdEntity();
//entity.codeId = "1100437";
entity.codeId = "1100139";
entity.codeGroup = "A";
entity.slotName = "video";
Debug.unityLogger.Log("加载激励视频");
ZXHCRewardAdUtil.Instance.LoadCacheRewardAd(entity,new Action<AdEntity>((cb)=> {
}));
}
public void OnClickShowRewardAd()
{
AdEntity entity = new AdEntity();
//entity.codeId = "1100437";
entity.codeId = "1100139";
entity.codeGroup = "A";
entity.slotName = "video";
Debug.unityLogger.Log("播放激励视频");
ZXHCRewardAdUtil.Instance.playCacheRewardAd(entity,new HcRewardAdListener(), new Action<bool>((cb) => {
}));
}
private sealed class HcRewardAdListener : ZXADRewardVideoListener
{
public void onAdClose(AdEntity entity)
{
Debug.unityLogger.Log("onAdClose");
}
public void onAdShow()
{
Debug.unityLogger.Log("onAdShow");
}
public void onAdVideoBarClick()
{
Debug.unityLogger.Log("onAdVideoBarClick");
}
public void onError(string errorMsg)
{
Debug.unityLogger.Log("onError");
}
public void onSuccess()
{
Debug.unityLogger.Log("onSuccess");
}
}
} }
} }

using System;
using System.Collections.Generic;
using UnityEngine;
public class ZXHCRewardAdUtil
{
private ZXHCRewardAdUtil() { }
private static readonly ZXHCRewardAdUtil singleInstance = new ZXHCRewardAdUtil();
public static ZXHCRewardAdUtil Instance
{
get
{
return singleInstance;
}
}
/// <summary>
/// 加载缓存激励视频
/// </summary>
/// <param name="entity"></param>
/// <param name="callback"></param>
public void LoadCacheRewardAd(AdEntity entity, Action<AdEntity> callback)
{
#if UNITY_ANDROID
ZxHcRewardAd rewardVideoAd = new ZxHcRewardAd();
rewardVideoAd.SetLoadListener(new RewardVideoAdLoadListener(this, entity, rewardVideoAd, callback));
rewardVideoAd.LoadHcRewardAd(entity.codeId);
#elif UNITY_IOS
callback(null);
#endif
}
/// <summary>
/// 播放缓存的激励视频
/// </summary>
/// <param name="entity"></param>
/// <param name="listener"></param>
/// <param name="callback"></param>
public void playCacheRewardAd(AdEntity entity, ZXADRewardVideoListener listener, Action<bool> callback)
{
ZxHcRewardAd rewardVideoAd = GetRewardVideoAd(entity.codeGroup + entity.slotName);
if (rewardVideoAd != null)
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "ZXHC REWARD Not NUll");
#if UNITY_ANDROID
rewardVideoAd.SetPlayListener(new RewardVideoAdListener(entity, callback, listener));
rewardVideoAd.ShowHcRewardAd();
#elif UNITY_IOS
callback(false);
#endif
}
else
{
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "ZXHC REWARD NUll");
callback(false);
}
}
private sealed class RewardVideoAdLoadListener : IZXHCRewardAdLoadListener
{
private ZXHCRewardAdUtil adUtil;
private AdEntity entity;
private ZxHcRewardAd rewardVideo;
private Action<AdEntity> callback;
public RewardVideoAdLoadListener(ZXHCRewardAdUtil adUtil, AdEntity entity, ZxHcRewardAd rewardVideo, Action<AdEntity> callback)
{
this.adUtil = adUtil;
this.entity = entity;
this.rewardVideo = rewardVideo;
this.callback = callback;
}
public void OnAdLoaded()
{
Debug.unityLogger.Log("ZXHC OnAdLoaded");
EventUtils.onEventPullSuccess(entity);
adUtil.SetRewardVideoAd(entity.codeGroup + entity.slotName, this.rewardVideo);
callback(entity);
}
public void OnLoadError(string error)
{
Debug.unityLogger.Log(entity.codeGroup + " codeID " + entity.codeId + "ZXHC Error code -1 message" + error);
EventUtils.onEventPullFail(entity, "-1", error);
callback(null);
}
}
private sealed class RewardVideoAdListener : IZXHCRewardAdShowListener
{
private AdEntity entity;
private Action<bool> callback;
private ZXADRewardVideoListener listener;
public RewardVideoAdListener(AdEntity entity, Action<bool> callback, ZXADRewardVideoListener listener)
{
this.entity = entity;
this.callback = callback;
this.listener = listener;
}
public void OnAdClicked()
{
EventUtils.onEventAdClick(entity);
listener.onAdVideoBarClick();
}
public void OnAdClosed()
{
listener.onAdClose(entity);
}
public void OnAdShow()
{
callback(true);
EventUtils.onEventShowSuccess(entity);
listener.onAdShow();
}
public void OnRewardVerify()
{
}
public void OnVideoCompleted()
{
EventUtils.onEventAdComplete(entity);
listener.onSuccess();
}
public void OnVideoError(string error)
{
callback(false);
EventUtils.onEventShowFail(entity);
listener.onError(error);
}
}
/// <summary>
/// 激励视频缓存队列
/// </summary>
private Dictionary<string, Queue<ZxHcRewardAd>> mRewardCacheMap = new Dictionary<string, Queue<ZxHcRewardAd>>();
/// <summary>
/// 保存缓存的激励视频
/// </summary>
/// <param name="codeId"></param>
/// <param name="reward"></param>
private void SetRewardVideoAd(string codeId, ZxHcRewardAd reward)
{
if (codeId == null || codeId == "")
{
return;
}
Queue<ZxHcRewardAd> mRewardQueue;
if (mRewardCacheMap.ContainsKey(codeId))
{
mRewardQueue = mRewardCacheMap[codeId];
}
else
{
mRewardQueue = new Queue<ZxHcRewardAd>();
}
mRewardQueue.Enqueue(reward);
mRewardCacheMap[codeId] = mRewardQueue;
}
/// <summary>
/// 取出缓存的激励视频
/// </summary>
/// <param name="codeId"></param>
/// <returns></returns>
private ZxHcRewardAd GetRewardVideoAd(string codeId)
{
if (mRewardCacheMap.ContainsKey(codeId))
{
Queue<ZxHcRewardAd> mRewardQueue = mRewardCacheMap[codeId];
if (mRewardQueue != null && mRewardQueue.Count > 0)
{
return mRewardQueue.Dequeue();
}
}
return null;
}
}
fileFormatVersion: 2
guid: a214be39d99931647abfc1ce6f10d2bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: 305b5d8890ba93743af4606cff50e132 guid: b48c4b5d5dae46b48988c0bfdb795067
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
fileFormatVersion: 2
guid: 44a8302e8f1c5b24092ae07c3f9beb62
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using Tencent.GDT;
using UnityEngine;
public class ZxHcRewardAd
{
/**激励视频广告**/
private AndroidJavaObject rewardAd;
private ZxHcRewardAdLoadListenerProxy loadListenerProxy;
private ZxHcRewardAdShowListenerProxy playListenerProxy;
public ZxHcRewardAd()
{
this.loadListenerProxy = new ZxHcRewardAdLoadListenerProxy();
this.playListenerProxy = new ZxHcRewardAdShowListenerProxy();
}
private void init(string codeId)
{
if (rewardAd == null)
{
rewardAd = new AndroidJavaObject("com.ym.zxhcsdk.view.ZXHCRewardVideoAD", Utils.GetActivity(), codeId);
}
}
/// <summary>
/// 设置加载监听
/// </summary>
/// <param name="listener"></param>
public void SetLoadListener(IZXHCRewardAdLoadListener listener)
{
loadListenerProxy.listener = listener;
}
/// <summary>
/// 设置播放监听
/// </summary>
/// <param name="listener"></param>
public void SetPlayListener(IZXHCRewardAdShowListener listener)
{
playListenerProxy.listener = listener;
}
/// <summary>
/// 加载激励视频广告
/// </summary>
/// <param name="codeId"></param>
public void LoadHcRewardAd(string codeId)
{
init(codeId);
Debug.unityLogger.Log("LoadZxhcRewardAd");
rewardAd.Call("loadRewardAD", loadListenerProxy);
}
/// <summary>
/// 播放激励视频广告
/// </summary>
/// <param name="codeId"></param>
public void ShowHcRewardAd()
{
Debug.unityLogger.Log("ShowZxHcRewardAd");
rewardAd.Call("showRewardAD", Utils.GetActivity(), playListenerProxy);
}
}
fileFormatVersion: 2
guid: 96945eef8bf3abb4f8775670b5554ff4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZxHcRewardAdLoadListenerProxy : AndroidJavaProxy
{
internal IZXHCRewardAdLoadListener listener = null;
public ZxHcRewardAdLoadListenerProxy() : base("com.ym.zxhcsdk.listener.RewardVideoAdLoadListener")
{
}
/// <summary>
/// 广告加载成功,可在此回调后进行广告展示
/// </summary>
void OnAdLoaded() {
if (listener == null)
{
return;
}
listener.OnAdLoaded();
}
/// <summary>
/// 激励视频广告各种错误信息回调
/// </summary>
void OnLoadError(string error) {
if (listener == null)
{
return;
}
listener.OnLoadError(error);
}
}
fileFormatVersion: 2
guid: c787281e925f9854599bc90e99f02e89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZxHcRewardAdShowListenerProxy : AndroidJavaProxy
{
internal IZXHCRewardAdShowListener listener = null;
public ZxHcRewardAdShowListenerProxy() : base("com.ym.zxhcsdk.listener.RewardVideoAdShowListener")
{
}
/// <summary>
/// 激励视频广告页面展示回调
/// </summary>
void OnAdShow() {
if (listener == null)
{
return;
}
listener.OnAdShow();
}
/// <summary>
/// 激励视频广告奖励
/// </summary>
void OnRewardVerify()
{
if (listener == null)
{
return;
}
listener.OnRewardVerify();
}
/// <summary>
/// 激励视频广告信息点击回调
/// </summary>
void OnAdClicked()
{
if (listener == null)
{
return;
}
listener.OnAdClicked();
}
/// <summary>
/// 激励视频广告播放完成回调
/// </summary>
void OnVideoCompleted()
{
if (listener == null)
{
return;
}
listener.OnVideoCompleted();
}
/// <summary>
/// 激励视频广告播放页关闭回调
/// </summary>
void OnAdClosed()
{
if (listener == null)
{
return;
}
listener.OnAdClosed();
}
/// <summary>
/// 激励视频广告各种错误信息回调
/// </summary>
void OnVideoError(string error)
{
if (listener == null)
{
return;
}
listener.OnVideoError(error);
}
}
fileFormatVersion: 2
guid: 189cc3754e0cef74694a1fe61c51731e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -11,7 +11,7 @@ namespace ZXHC ...@@ -11,7 +11,7 @@ namespace ZXHC
private static bool hasInit = false; private static bool hasInit = false;
public static bool Init(string appId,bool IsDebug) public static bool Init(string appId,bool IsDebug)
{ {
#if UNITY_ANDROID #if UNITY_ANDROID&&!UNITY_EDITOR
AndroidJavaObject hcAdManager = new AndroidJavaClass("com.ym.zxhcsdk.manager.ZXHCADManager").CallStatic<AndroidJavaObject>("getInstance"); AndroidJavaObject hcAdManager = new AndroidJavaClass("com.ym.zxhcsdk.manager.ZXHCADManager").CallStatic<AndroidJavaObject>("getInstance");
hasInit = hcAdManager.Call<bool>("InitAd",ZXHCUtils.GetActivity(),appId, IsDebug); hasInit = hcAdManager.Call<bool>("InitAd",ZXHCUtils.GetActivity(),appId, IsDebug);
//OaidUtil.GetOaid(new Action<string>((oaid) => { //OaidUtil.GetOaid(new Action<string>((oaid) => {
...@@ -21,6 +21,8 @@ namespace ZXHC ...@@ -21,6 +21,8 @@ namespace ZXHC
#elif UNITY_IOS #elif UNITY_IOS
return hasInit; return hasInit;
#endif #endif
Debug.unityLogger.Log("ZXHCADManager Init 失败");
return false;
} }
internal static bool CheckInit() internal static bool CheckInit()
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface IZXHCRewardAdLoadListener
{
/// <summary>
/// 广告加载成功,可在此回调后进行广告展示
/// </summary>
void OnAdLoaded();
/// <summary>
/// 激励视频广告各种错误信息回调
/// </summary>
void OnLoadError(string error);
}
fileFormatVersion: 2
guid: a0f9bcabed381e64db0693c314f8a412
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface IZXHCRewardAdShowListener
{
/// <summary>
/// 激励视频广告页面展示回调
/// </summary>
void OnAdShow();
/// <summary>
/// 激励视频广告奖励
/// </summary>
void OnRewardVerify();
/// <summary>
/// 激励视频广告信息点击回调
/// </summary>
void OnAdClicked();
/// <summary>
/// 激励视频广告播放完成回调
/// </summary>
void OnVideoCompleted();
/// <summary>
/// 激励视频广告播放页关闭回调
/// </summary>
void OnAdClosed();
/// <summary>
/// 激励视频广告各种错误信息回调
/// </summary>
void OnVideoError(string error);
}
fileFormatVersion: 2
guid: fcb40fe12884ec5479f0b668d9c3f692
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -11,10 +11,10 @@ EditorBuildSettings: ...@@ -11,10 +11,10 @@ EditorBuildSettings:
- enabled: 0 - enabled: 0
path: Assets/AdSDK/AD/GDT/UnionDemo/UnionExample.unity path: Assets/AdSDK/AD/GDT/UnionDemo/UnionExample.unity
guid: 6c963ae210fa3c3438c2f6770ee81fc9 guid: 6c963ae210fa3c3438c2f6770ee81fc9
- enabled: 1 - enabled: 0
path: Assets/AdSDK/AD/Demo/AdDemo.unity path: Assets/AdSDK/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2 guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 0 - enabled: 1
path: Assets/AdSDK/AD/ZXHC/ZXHCDemo/ZXHCDemo.unity path: Assets/AdSDK/AD/ZXHC/ZXHCDemo/ZXHCDemo.unity
guid: cb50b98bfef171a4ea884c941dd43fa3 guid: cb50b98bfef171a4ea884c941dd43fa3
- enabled: 0 - enabled: 0
......
...@@ -131,7 +131,7 @@ PlayerSettings: ...@@ -131,7 +131,7 @@ PlayerSettings:
16:10: 1 16:10: 1
16:9: 1 16:9: 1
Others: 1 Others: 1
bundleVersion: 1.0.5 bundleVersion: 1.0.6
preloadedAssets: [] preloadedAssets: []
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
...@@ -175,7 +175,7 @@ PlayerSettings: ...@@ -175,7 +175,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1 androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1 androidMaxAspectRatio: 2.1
applicationIdentifier: applicationIdentifier:
Android: com.ym.cscmnq Android: com.ym.chxxx
Lumin: com.DefaultCompany.com.unity.template.mobile2D Lumin: com.DefaultCompany.com.unity.template.mobile2D
Standalone: com.DefaultCompany.com.unity.template.mobile2D Standalone: com.DefaultCompany.com.unity.template.mobile2D
iPhone: com.ym.iosawpdd iPhone: com.ym.iosawpdd
...@@ -184,7 +184,7 @@ PlayerSettings: ...@@ -184,7 +184,7 @@ PlayerSettings:
Standalone: 0 Standalone: 0
iPhone: 0 iPhone: 0
tvOS: 0 tvOS: 0
AndroidBundleVersionCode: 6 AndroidBundleVersionCode: 7
AndroidMinSdkVersion: 21 AndroidMinSdkVersion: 21
AndroidTargetSdkVersion: 0 AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1 AndroidPreferredInstallLocation: 1
......
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