Commit 3df60f0d authored by 王雪伟's avatar 王雪伟

解决平台切换报错

parent 71924495
...@@ -103,10 +103,11 @@ public class AdManager ...@@ -103,10 +103,11 @@ public class AdManager
#endif #endif
break; break;
case ZXADConfig.PLANTFORM_AD_FS: case ZXADConfig.PLANTFORM_AD_FS:
#if UNITY_ANDROID
AndroidJavaClass jc3 = new AndroidJavaClass("com.ym.admodule.fs.FunShionManager"); AndroidJavaClass jc3 = new AndroidJavaClass("com.ym.admodule.fs.FunShionManager");
jc3.CallStatic("init"); jc3.CallStatic("init");
#endif
break; break;
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持初始化" + id.adPlatform + "的广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持初始化" + id.adPlatform + "的广告");
break; break;
...@@ -131,6 +132,7 @@ public class AdManager ...@@ -131,6 +132,7 @@ public class AdManager
if (!IsInitAd) if (!IsInitAd)
{ {
listener.onError("没有初始化"); listener.onError("没有初始化");
listener.onLastError();
return; return;
} }
Dictionary<string, object> paras = new Dictionary<string, object>(); Dictionary<string, object> paras = new Dictionary<string, object>();
...@@ -235,14 +237,18 @@ public class AdManager ...@@ -235,14 +237,18 @@ public class AdManager
//广点通开屏广告 //广点通开屏广告
GDTSplshAdUtils.Instance.LoadSplshAd(entity, listener, callback); GDTSplshAdUtils.Instance.LoadSplshAd(entity, listener, callback);
break; break;
#if UNITY_ANDROID
case ZXADConfig.PLANTFORM_AD_ZXHC: case ZXADConfig.PLANTFORM_AD_ZXHC:
//掌心汇川开屏广告 //掌心汇川开屏广告
ZXHCSplashUtil.Instance.LoadSplshAd(entity, listener, callback); ZXHCSplashUtil.Instance.LoadSplshAd(entity, listener, callback);
break; break;
#endif
#if UNITY_ANDROID
//风行开屏广告 //风行开屏广告
case ZXADConfig.PLANTFORM_AD_FS: case ZXADConfig.PLANTFORM_AD_FS:
FSSplashUtil.Instance.loadSplashAd(entity, listener, callback); FSSplashUtil.Instance.loadSplashAd(entity, listener, callback);
break; break;
#endif
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持加载" + entity.adPlatform + "的Splash广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持加载" + entity.adPlatform + "的Splash广告");
callback(false); callback(false);
...@@ -1126,10 +1132,12 @@ public class AdManager ...@@ -1126,10 +1132,12 @@ public class AdManager
//优良宝激励视频广告加载 //优良宝激励视频广告加载
YLBRewardAdUtil.Instance.LoadCacheRewardAd(entity, callback); YLBRewardAdUtil.Instance.LoadCacheRewardAd(entity, callback);
break; break;
//风行激励视频广告 #if UNITY_ANDROID
//风行激励视频广告
case ZXADConfig.PLANTFORM_AD_FS: case ZXADConfig.PLANTFORM_AD_FS:
FSRewardUtils.Instance.LoadCacheRewardAd(entity, callback); FSRewardUtils.Instance.LoadCacheRewardAd(entity, callback);
break; break;
#endif
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持加载" + entity.adPlatform + "的激励视频广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持加载" + entity.adPlatform + "的激励视频广告");
callback(null); callback(null);
...@@ -1236,10 +1244,12 @@ public class AdManager ...@@ -1236,10 +1244,12 @@ public class AdManager
//优良宝激励视频广告播放 //优良宝激励视频广告播放
YLBRewardAdUtil.Instance.playCacheRewardAd(entity, listener, callback); YLBRewardAdUtil.Instance.playCacheRewardAd(entity, listener, callback);
break; break;
#if UNITY_ANDROID
//风行激励视频广告 //风行激励视频广告
case ZXADConfig.PLANTFORM_AD_FS: case ZXADConfig.PLANTFORM_AD_FS:
FSRewardUtils.Instance.playCacheRewardAd(entity, listener, callback); FSRewardUtils.Instance.playCacheRewardAd(entity, listener, callback);
break; break;
#endif
default: default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持Show" + entity.adPlatform + "的激励视频广告"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持Show" + entity.adPlatform + "的激励视频广告");
callback(false); callback(false);
......
...@@ -145,7 +145,7 @@ public class CSJRewardUtil ...@@ -145,7 +145,7 @@ public class CSJRewardUtil
#if UNITY_IOS #if UNITY_IOS
EventUtils.onEventPullSuccess(entity); EventUtils.onEventPullSuccess(entity);
this.csjAD.SetRewardVideoAdForIOS(entity.codeGroup + entity.slotName, ad); this.csjAD.SetRewardVideoAdForIOS(entity.codeGroup + entity.slotName, ad);
callback(true); callback(entity);
#endif #endif
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
#if UNITY_ANDROID
public class FSRewardUtils public class FSRewardUtils
{ {
private FSRewardUtils() { } private FSRewardUtils() { }
...@@ -27,7 +27,7 @@ public class FSRewardUtils ...@@ -27,7 +27,7 @@ public class FSRewardUtils
rewardVideoAd.SetLoadListener(new RewardVideoAdLoadListener(this, entity, rewardVideoAd, callback)); rewardVideoAd.SetLoadListener(new RewardVideoAdLoadListener(this, entity, rewardVideoAd, callback));
rewardVideoAd.LoadAd(entity.codeId, entity.codeGroup); rewardVideoAd.LoadAd(entity.codeId, entity.codeGroup);
#elif UNITY_IOS #elif UNITY_IOS
callback(false); callback(null);
#endif #endif
} }
...@@ -39,23 +39,23 @@ public class FSRewardUtils ...@@ -39,23 +39,23 @@ public class FSRewardUtils
/// <param name="callback"></param> /// <param name="callback"></param>
public void playCacheRewardAd(AdEntity entity, ZXADRewardVideoListener listener, Action<bool> callback) public void playCacheRewardAd(AdEntity entity, ZXADRewardVideoListener listener, Action<bool> callback)
{ {
#if UNITY_ANDROID
FSManager rewardVideoAd = GetRewardVideoAd(entity.codeGroup + entity.slotName); FSManager rewardVideoAd = GetRewardVideoAd(entity.codeGroup + entity.slotName);
if (rewardVideoAd != null) if (rewardVideoAd != null)
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "YLB Not NUll"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "YLB Not NUll");
#if UNITY_ANDROID
rewardVideoAd.SetPlayListener(new RewardVideoAdListener(entity, callback, listener)); rewardVideoAd.SetPlayListener(new RewardVideoAdListener(entity, callback, listener));
rewardVideoAd.ShowAD(entity.codeId, entity.codeGroup); rewardVideoAd.ShowAD(entity.codeId, entity.codeGroup);
#elif UNITY_IOS
callback(false);
#endif
} }
else else
{ {
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "YLB NUll"); Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, entity.codeGroup + "YLB NUll");
callback(false); callback(false);
} }
#elif UNITY_IOS
callback(false);
#endif
} }
private sealed class RewardVideoAdLoadListener : IFSRewardVideoAdLoadListener private sealed class RewardVideoAdLoadListener : IFSRewardVideoAdLoadListener
...@@ -198,3 +198,4 @@ public class FSRewardUtils ...@@ -198,3 +198,4 @@ public class FSRewardUtils
} }
} }
#endif
\ No newline at end of file
...@@ -35,7 +35,7 @@ public class YLBRewardAdUtil ...@@ -35,7 +35,7 @@ public class YLBRewardAdUtil
rewardVideoAd.SetLoadListener(new RewardVideoAdLoadListener(this,entity,rewardVideoAd,callback)); rewardVideoAd.SetLoadListener(new RewardVideoAdLoadListener(this,entity,rewardVideoAd,callback));
rewardVideoAd.LoadAd(entity.codeId, entity.codeGroup); rewardVideoAd.LoadAd(entity.codeId, entity.codeGroup);
#elif UNITY_IOS #elif UNITY_IOS
callback(false); callback(null);
#endif #endif
} }
......
...@@ -20,12 +20,14 @@ namespace ZXHC ...@@ -20,12 +20,14 @@ namespace ZXHC
public void OnClickSplash() public void OnClickSplash()
{ {
#if UNITY_ANDROID
AdEntity entity = new AdEntity(); AdEntity entity = new AdEntity();
entity.codeId = "1100028"; entity.codeId = "1100028";
ZXHCSplashUtil.Instance.LoadSplshAd(entity, new SplshAdListener(), new Action<bool>((cb) => { ZXHCSplashUtil.Instance.LoadSplshAd(entity, new SplshAdListener(), new Action<bool>((cb) => {
Debug.unityLogger.Log("开屏jiazai"+ cb); Debug.unityLogger.Log("开屏jiazai"+ cb);
})); }));
#endif
} }
public void OnClickFeed() public void OnClickFeed()
......
...@@ -3,6 +3,7 @@ using System.Collections; ...@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using ZXHC; using ZXHC;
#if UNITY_ANDROID
public class ZXHCSplashUtil public class ZXHCSplashUtil
{ {
private ZXHCSplashUtil() { } private ZXHCSplashUtil() { }
...@@ -17,16 +18,7 @@ public class ZXHCSplashUtil ...@@ -17,16 +18,7 @@ public class ZXHCSplashUtil
private ZXHCSplashAd hcSplshad; private ZXHCSplashAd hcSplshad;
#if UNITY_ANDROID
private static AndroidJavaObject container; private static AndroidJavaObject container;
#elif UNITY_IOS
#endif
#if UNITY_IOS
#endif
/// <summary> /// <summary>
/// ZXHC 开屏广告 /// ZXHC 开屏广告
/// </summary> /// </summary>
...@@ -76,13 +68,9 @@ public class ZXHCSplashUtil ...@@ -76,13 +68,9 @@ public class ZXHCSplashUtil
{ {
callback(true); callback(true);
//EventUtils.onEventPullSuccess(entity); //EventUtils.onEventPullSuccess(entity);
#if UNITY_ANDROID
// Android 要求开屏 container 必须是 c# 的 AndroidJavaObject 类型,必须是 Java(Android)上的 ViewGroup 类型 // Android 要求开屏 container 必须是 c# 的 AndroidJavaObject 类型,必须是 Java(Android)上的 ViewGroup 类型
container = ZXHCUtils.NewAdContainer(); container = ZXHCUtils.NewAdContainer();
ZXHCUtils.ShowView(container, false); ZXHCUtils.ShowView(container, false);
#elif UNITY_IOS
#endif
this.hcAdUtils.hcSplshad.Show(container); this.hcAdUtils.hcSplshad.Show(container);
} }
...@@ -99,6 +87,5 @@ public class ZXHCSplashUtil ...@@ -99,6 +87,5 @@ public class ZXHCSplashUtil
callback(false); callback(false);
} }
} }
} }
#endif
\ No newline at end of file
...@@ -75,7 +75,8 @@ public class InitProject : MonoBehaviour ...@@ -75,7 +75,8 @@ public class InitProject : MonoBehaviour
SceneManager.LoadSceneAsync(1); SceneManager.LoadSceneAsync(1);
})); }));
#else #else
callback("不支持"); //加载游戏场景
SceneManager.LoadSceneAsync(1);
#endif #endif
} }
......
...@@ -245,6 +245,8 @@ namespace EncryptHelper ...@@ -245,6 +245,8 @@ namespace EncryptHelper
return Encoding.UTF8.GetString(original); return Encoding.UTF8.GetString(original);
} }
public static string ADCSD(string v,string v2) public static string ADCSD(string v,string v2)
{ {
string value; string value;
...@@ -445,6 +447,31 @@ namespace EncryptHelper ...@@ -445,6 +447,31 @@ namespace EncryptHelper
return temp; return temp;
} }
/// <summary>
/// MD5加密
/// </summary>
/// <param name="value">需要加密字符串</param>
/// <returns>返回32位大写字符</returns>
public static string MD5Encrypt(string value)
{
//将输入字符串转换成字节数组 ANSI代码页编码
var buffer = Encoding.Default.GetBytes(value);
//接着,创建Md5对象进行散列计算
var data = MD5.Create().ComputeHash(buffer);
//创建一个新的Stringbuilder收集字节
var sb = new StringBuilder();
//遍历每个字节的散列数据
foreach (var t in data)
{
//转换大写十六进制字符串
// X2 大写
// x2 小写
sb.Append(t.ToString("x2"));
}
//返回十六进制字符串
return sb.ToString();
}
} }
......
...@@ -310,53 +310,43 @@ public class HttpTool : MonoBehaviour ...@@ -310,53 +310,43 @@ public class HttpTool : MonoBehaviour
#if UNITY_IOS #if UNITY_IOS
//paragrams.Add("pkg", "com.ym.animalspa"); paragrams["pkg"] = Application.identifier;
//paragrams.Add("appLs", appLs); paragrams["appLs"] = appLs;
//paragrams.Add("ts", UserInfoManager.getInstance().GetTimeStamp()); paragrams["ts"] = UserInfoManager.Instance().GetTimeStamp();
//paragrams.Add("platform", "ios"); paragrams["platform"] = "ios";
//paragrams.Add("source", "AppStore"); paragrams["source"] = "AppStore";
//paragrams.Add("module", "behavior"); paragrams["module"] = "behavior";
//paragrams.Add("ua", "Safari"); paragrams["ntt"] = "4G";
//paragrams.Add("ntt", "4G"); if (UserInfoManager.Instance().udid.Length > 0)
////paragrams.Add("device", "d0ff4c9b53d1688fc81ce8d730b2989a"); {
//if (UserInfoManager.getInstance().udid.Length > 0) paragrams["device"] = UserInfoManager.Instance().udid;
//{ }
// paragrams.Add("device", UserInfoManager.getInstance().udid); if (UserInfoManager.Instance().build.Length > 0)
//} {
//if (UserInfoManager.getInstance().build.Length > 0) paragrams["vc"] = UserInfoManager.Instance().build;
//{ }
// paragrams.Add("vc", UserInfoManager.getInstance().build); if (UserInfoManager.Instance().version.Length > 0)
//} {
//if (UserInfoManager.getInstance().version.Length > 0) paragrams["vn"] = UserInfoManager.Instance().version;
//{ }
// paragrams.Add("vn", UserInfoManager.getInstance().version); if (UserInfoManager.Instance().idfa.Length > 0)
//} {
//if (UserInfoManager.getInstance().idfa.Length > 0) paragrams["idfa"] = UserInfoManager.Instance().idfa;
//{ }
// paragrams.Add("idfa", UserInfoManager.getInstance().idfa); if (PrefenceUtils.GetInstance().getToken().Length > 0)
//} {
//if (UserInfoManager.getInstance().token.Length > 0) paragrams["token"] = PrefenceUtils.GetInstance().getToken();
//{ }
// paragrams.Add("token", UserInfoManager.getInstance().token); if (IS_TGYZ)
//} {
//if (UserInfoManager.getInstance().uid > 0) paragrams["zygt"] = "hzwz";
//{ paragrams["tgtk"] = "1";
// paragrams.Add("uid", UserInfoManager.getInstance().uid + ""); paragrams["uid"] = "1";
//} }
else
//if (IS_TGYZ) {
paragrams["uid"] = PrefenceUtils.GetInstance().getUid();
//{ }
// paragrams["zygt"] = "hzwz";
// paragrams["tgtk"] = "1";
//}
//string signString = signParamsWithDict(paragrams);
//paragrams.Add("sign", signString);
#elif UNITY_ANDROID #elif UNITY_ANDROID
if (IS_TGYZ) if (IS_TGYZ)
...@@ -404,12 +394,10 @@ public class HttpTool : MonoBehaviour ...@@ -404,12 +394,10 @@ public class HttpTool : MonoBehaviour
paragrams["platform"] = "android"; paragrams["platform"] = "android";
paragrams["source"] = PrefenceUtils.GetInstance().getSource(); paragrams["source"] = PrefenceUtils.GetInstance().getSource();
paragrams["ua"] = PrefenceUtils.GetInstance().getUA(); paragrams["ua"] = PrefenceUtils.GetInstance().getUA();
#endif
string signString = signParamsWithDict(paragrams); string signString = signParamsWithDict(paragrams);
paragrams["sign"] = signString; paragrams["sign"] = signString;
#endif
foreach (KeyValuePair<string, object> item in paragrams) foreach (KeyValuePair<string, object> item in paragrams)
{ {
......
fileFormatVersion: 2
guid: cf594f8632f819c40a71457766b36898
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using LitJson;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Text;
using System.IO;
// 用户单例
public class UserInfoManager : MonoBehaviour
{
private static UserInfoManager instance;
public static UserInfoManager Instance()
{
if (instance == null)
{
GameObject obj = new GameObject();
// 设置对象名字为脚本名
obj.name = typeof(UserInfoManager).ToString();
// 让这个单例模式对象 切换场景不移除
DontDestroyOnLoad(obj);
instance = obj.AddComponent<UserInfoManager>();
}
return instance;
}
// 钻石
public int avaDiamond = 0;
// 金币
public int avaCoin = 0;
// UDID
public string udid = "udid";
// IDFA
public string idfa = "";
public string token = "";
public string uid = "";
public string build = "1";
public string version = "1.0.0";
public int shubiao; // 0 shen 1 tou
public bool isBind = false; // 是否绑定wx
// public void touristLogin(Action<string> success, Action<string> fail)
// {
// NetworkTool.Instance().Post(HttpManager.URL_TOURIST_LOGIN, null, new Action<string, LoginResult>((res, model) => {
// this.token = model.token;
// this.uid = model.uid + "";
// success(res);
// AppInfo();
// }), new Action<string>((error) => {
// fail(error);
// AppInfo();
// }));
// }
// public void AppInfo()
// {
// NetworkTool.Instance().GET(HttpManager.URL_INFO, null, new Action<string, AppInfoResult>((res, model) => {
// shubiao = model.sdgowi["shubiao"];
//#if UNITY_ANDROID
// shubiao = 1;
//#endif
// IsBindWx();
// }), new Action<string>((error) => {
// IsBindWx();
// }));
// }
// public void IsBindWx()
// {
// NetworkTool.Instance().GET(HttpManager.URL_IS_BIND_WX, null, new Action<string, AppInfoBind>((res, model) => {
// isBind = model.isBind;
// Messenger.Broadcast("RefreshWXBind");
// }), new Action<string>((error) => {
// Messenger.Broadcast("RefreshWXBind");
// }));
// }
// 随机code
public string CreateRandomCode()
{
string str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char[] chars = str.ToCharArray();
StringBuilder strRan = new StringBuilder();
System.Random ran = new System.Random();
for (int i = 0; i < 16; i++)
{
strRan.Append(chars[ran.Next(0, 62)]);
}
return strRan.ToString();
}
// 时间戳毫秒
public string GetTimeStamp()
{
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
string time = Convert.ToInt64(ts.TotalSeconds - 8 * 3600).ToString() + "000";
return time;
}
// 时间戳秒
public string TimeSecond()
{
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
string time = Convert.ToInt64(ts.TotalSeconds - 8 * 3600).ToString();
return time;
}
}
fileFormatVersion: 2
guid: 6194b988913647a4ea9eae145329158c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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