using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using Newtonsoft.Json; using UnityEngine; using SolarEngine.Singleton; namespace SolarEngine { public class SESDKBridge : SingletonMonoBehaviour { private string version = "1.0.6"; public const string WishlistType_DEFAULT = "default"; public const string WishlistType_MY = "my"; public const string WishlistType_DESKTOP = "desktop"; public const string WishlistType_OTHERS = "others"; public const string ShareTarget_APP_MESSAGE = "APP_MESSAGE"; public const string ShareTarget_TIME_LINE = "TIME_LINE"; #if !UNITY_EDITOR&&(SE_DG||SE_WG) [DllImport("__Internal")] private static extern void _log(bool isdebug); [DllImport("__Internal")] private static extern void _ready(); #if SE_DG [DllImport("__Internal")] private static extern void _prevInit_dy(string appkey); [DllImport("__Internal")] private static extern void _init_dy(string initParams); [DllImport("__Internal")] private static extern void _abtestuse_dy(); [DllImport("__Internal")] private static extern void _setRemoteDefaultConfig_dy(string config); [DllImport("__Internal")] private static extern void _setRemoteConfigEventProperties_dy(string properties); [DllImport("__Internal")] private static extern void _setRemoteConfigUserProperties_dy(string properties); [DllImport("__Internal")] private static extern string _fastFetchRemoteConfig_dy(string key); [DllImport("__Internal")] private static extern void _asyncFetchRemoteConfig_dy(string key); [DllImport("__Internal")] private static extern void _setVisitorId_dy(string visitorId); [DllImport("__Internal")] private static extern string _getVisitorId_dy(); [DllImport("__Internal")] private static extern void _login_dy(string accountId); [DllImport("__Internal")] private static extern string _getAccountId_dy(); [DllImport("__Internal")] private static extern void _logout_dy(); [DllImport("__Internal")] private static extern void _setSuperProperties_dy(string propertiesJson); [DllImport("__Internal")] private static extern void _unsetSuperProperty_dy(string key); [DllImport("__Internal")] private static extern void _clearSuperProperties_dy(); [DllImport("__Internal")] private static extern void _setPresetEvent_dy(string eventType, string properties); [DllImport("__Internal")] private static extern void _setChannel_dy(string channel); [DllImport("__Internal")] private static extern void _setReferrerTitle_dy(string referrer_title); [DllImport("__Internal")] private static extern void _setXcxPageTitle_dy(string page_title); [DllImport("__Internal")] private static extern void _trackAdImpression_dy(string data); [DllImport("__Internal")] private static extern void _trackAdClick_dy(string data); [DllImport("__Internal")] private static extern void _trackIAP_dy(string data); [DllImport("__Internal")] private static extern void _trackAppAttr_dy(string data); [DllImport("__Internal")] private static extern void _trackOrder_dy(string data); [DllImport("__Internal")] private static extern void _trackRegister_dy(string data); [DllImport("__Internal")] private static extern void _trackLogin_dy(string data); [DllImport("__Internal")] private static extern void _track_dy(string eventName, string data); [DllImport("__Internal")] private static extern void _eventStart_dy(string eventName); [DllImport("__Internal")] private static extern void _eventFinish_dy(string eventName, string data); [DllImport("__Internal")] private static extern void _userInit_dy(string userdata); [DllImport("__Internal")] private static extern void _userUpdate_dy(string Update); [DllImport("__Internal")] private static extern void _userAdd_dy(string userAdd); [DllImport("__Internal")] private static extern void _userAppend_dy(string userAppend); [DllImport("__Internal")] private static extern void _userUnset_dy(string userUnset); [DllImport("__Internal")] private static extern void _userDelete_dy(string deleteType); [DllImport("__Internal")] private static extern void _setOnAttributionListener_dy(); [DllImport("__Internal")] private static extern void _getAttribution_dy(); [DllImport("__Internal")] private static extern void _setPluginProperties_dy(string paramJson); [DllImport("__Internal")] private static extern void _getDistinct_dy(); #elif SE_WG [DllImport("__Internal")] private static extern void _prevInit_wx(string appkey); [DllImport("__Internal")] private static extern void _init_wx(string initParams); [DllImport("__Internal")] private static extern void _abtestuse_wx(); [DllImport("__Internal")] private static extern void _setRemoteDefaultConfig_wx(string config); [DllImport("__Internal")] private static extern void _setRemoteConfigEventProperties_wx(string properties); [DllImport("__Internal")] private static extern void _setRemoteConfigUserProperties_wx(string properties); [DllImport("__Internal")] private static extern string _fastFetchRemoteConfig_wx(string key); [DllImport("__Internal")] private static extern void _asyncFetchRemoteConfig_wx(string key); [DllImport("__Internal")] private static extern void _setVisitorId_wx(string visitorId); [DllImport("__Internal")] private static extern string _getVisitorId_wx(); [DllImport("__Internal")] private static extern void _login_wx(string accountId); [DllImport("__Internal")] private static extern string _getAccountId_wx(); [DllImport("__Internal")] private static extern void _logout_wx(); [DllImport("__Internal")] private static extern void _setSuperProperties_wx(string propertiesJson); [DllImport("__Internal")] private static extern void _unsetSuperProperty_wx(string key); [DllImport("__Internal")] private static extern void _clearSuperProperties_wx(); [DllImport("__Internal")] private static extern void _setPresetEvent_wx(string eventType, string properties); [DllImport("__Internal")] private static extern void _setChannel_wx(string channel); [DllImport("__Internal")] private static extern void _setReferrerTitle_wx(string referrer_title); [DllImport("__Internal")] private static extern void _setXcxPageTitle_wx(string page_title); [DllImport("__Internal")] private static extern void _trackAdImpression_wx(string data); [DllImport("__Internal")] private static extern void _trackAdClick_wx(string data); [DllImport("__Internal")] private static extern void _trackIAP_wx(string data); [DllImport("__Internal")] private static extern void _trackAppAttr_wx(string data); [DllImport("__Internal")] private static extern void _trackOrder_wx(string data); [DllImport("__Internal")] private static extern void _trackRegister_wx(string data); [DllImport("__Internal")] private static extern void _trackLogin_wx(string data); [DllImport("__Internal")] private static extern void _track_wx(string eventName, string data); [DllImport("__Internal")] private static extern void _eventStart_wx(string eventName); [DllImport("__Internal")] private static extern void _eventFinish_wx(string eventName, string data); [DllImport("__Internal")] private static extern void _userInit_wx(string userdata); [DllImport("__Internal")] private static extern void _userUpdate_wx(string Update); [DllImport("__Internal")] private static extern void _userAdd_wx(string userAdd); [DllImport("__Internal")] private static extern void _userAppend_wx(string userAppend); [DllImport("__Internal")] private static extern void _userUnset_wx(string userUnset); [DllImport("__Internal")] private static extern void _userDelete_wx(string deleteType); [DllImport("__Internal")] private static extern void _setOnAttributionListener_wx(); [DllImport("__Internal")] private static extern void _getAttribution_wx(); [DllImport("__Internal")] private static extern void _setPluginProperties_wx(string paramJson); [DllImport("__Internal")] private static extern void _getDistinct_wx(); [DllImport("__Internal")] private static extern void _trackReActive_wx(string data); [DllImport("__Internal")] private static extern void _trackAddToWishlist_wx(string data); [DllImport("__Internal")] private static extern void _trackShare_wx(string data); [DllImport("__Internal")] private static extern void _trackCreateRole_wx(string data); [DllImport("__Internal")] private static extern void _trackTutorialFinish_wx(string data); [DllImport("__Internal")] private static extern void _trackUpdateLevel_wx(string data); [DllImport("__Internal")] private static extern void _trackViewContentMall_wx(string data); [DllImport("__Internal")] private static extern void _trackViewContentActivity_wx(string data); #endif #endif public delegate void DistinctCalllback(Distinct result); private DistinctCalllback distinctCalllback = null; public delegate void AttributionCalllback(string result); AttributionCalllback setattributioncallback = null; AttributionCalllback getattributioncallback = null; public delegate void InitReadyCalllBack(); public InitReadyCalllBack initReadyCalllBack = null; public delegate void AsyncFetchRemoteConfigCallBack(object result); //AsyncFetchRemoteConfigCallBack asyncFetchRemoteConfigCallBack= null; private Dictionary asyncFetchRemoteConfigCallBacks = new Dictionary(); private bool debug = false; /// /// log开关 只能控制unity和桥接层文件 /// /// public void log(bool isdebug) { try { debug = isdebug; #if UNITY_EDITOR return; #elif SE_DG||SE_WG _log(isdebug); #endif } catch (Exception e) { Debug.LogError("log:" + e); throw; } } public void Awake() { #if UNITY_EDITOR return; #if SE_WG&&SE_DG Debug.LogError("SE_WG and SE_DG can only have one at a time"); return; #endif #endif setPluginProperties(); } /// /// 预初始化 /// /// public void prevInit(string appkey) { #if UNITY_EDITOR return; #elif SE_WG _prevInit_wx(appkey); #elif SE_DG _prevInit_dy(appkey); #endif } /// /// 初始化 /// /// public void init(InitParams initParams) { string json = JsonConvert.SerializeObject(initParams, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _init_wx(json); #elif SE_DG _init_dy(json); #endif } private void setPluginProperties() { try { Dictionary dict = new Dictionary { { "_sdk_type", "unity" }, { "_sub_lib_version", version }, }; string paramJson = JsonConvert.SerializeObject(dict); Debug.Log(paramJson); #if UNITY_EDITOR return; #elif SE_WG Debug.Log("_setPluginProperties_wx"); _setPluginProperties_wx(paramJson); #elif SE_DG _setPluginProperties_dy(paramJson); #endif } catch (Exception e) { Debug.LogError("setPluginProperties:" + e); throw; } } public void setRemoteDefaultConfig(DefaultConfig[] defaultConfig) { try { string jsonString = JsonConvert.SerializeObject(defaultConfig); if (debug) Debug.Log(jsonString); #if UNITY_EDITOR return; #elif SE_WG _setRemoteDefaultConfig_wx(jsonString); #elif SE_DG _setRemoteDefaultConfig_dy(jsonString); #endif } catch (Exception e) { Debug.LogError("setRemoteDefaultConfig:" + e); throw; } } public void setRemoteConfigEventProperties(Dictionary properties) { try { string jsonString = JsonConvert.SerializeObject(properties); if (debug) Debug.Log(jsonString); #if UNITY_EDITOR return; #elif SE_WG _setRemoteConfigEventProperties_wx(jsonString); #elif SE_DG _setRemoteConfigEventProperties_dy(jsonString); #endif } catch (Exception e) { Debug.LogError("setRemoteConfigEventProperties:" + e); throw; } } public void setRemoteConfigUserProperties(Dictionary properties) { try { string jsonString = JsonConvert.SerializeObject(properties); if (debug) Debug.Log(jsonString); #if UNITY_EDITOR return; #elif SE_WG _setRemoteConfigUserProperties_wx(jsonString); #elif SE_DG _setRemoteConfigUserProperties_dy(jsonString); #endif } catch (Exception e) { Debug.LogError("setRemoteConfigUserProperties:" + e); throw; } } public string fastFetchRemoteConfig(string key) { try { #if UNITY_EDITOR return""; #elif SE_WG return _fastFetchRemoteConfig_wx(key); #elif SE_DG return _fastFetchRemoteConfig_dy(key); #endif } catch (Exception e) { Debug.LogError("fastFetchRemoteConfig:" + e); throw; } return ""; } public void asyncFetchRemoteConfig(string key, AsyncFetchRemoteConfigCallBack callBack) { try { //asyncFetchRemoteConfigCallBack = callBack; if (asyncFetchRemoteConfigCallBacks.ContainsKey(key)) { asyncFetchRemoteConfigCallBacks[key] = callBack; } else { asyncFetchRemoteConfigCallBacks.Add(key, callBack); } #if UNITY_EDITOR return; #elif SE_WG _asyncFetchRemoteConfig_wx(key); #elif SE_DG _asyncFetchRemoteConfig_dy(key); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } /// /// 加载在线参数SDK插件 /// public void abtestuse() { try { #if UNITY_EDITOR return; #elif SE_WG _abtestuse_wx(); #elif SE_DG _abtestuse_dy(); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } /// /// /// /// public void setVisitorId(string visitorId) { try { #if UNITY_EDITOR return; #elif SE_WG _setVisitorId_wx(visitorId); #elif SE_DG _setVisitorId_dy(visitorId); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public string getVisitorId() { try { #if UNITY_EDITOR return""; #elif SE_WG return _getVisitorId_wx(); #elif SE_DG return _getVisitorId_dy(); #endif } catch (Exception e) { Console.WriteLine(e); throw; } return ""; } public void getDistinct(DistinctCalllback calllback) { try { distinctCalllback = calllback; #if UNITY_EDITOR return; #elif SE_WG _getDistinct_wx(); #elif SE_DG _getDistinct_dy(); #endif } catch (Exception e) { Debug.LogError("getDistinct: " + e); throw; } } public void login(string accountId) { try { #if UNITY_EDITOR return; #elif SE_WG _login_wx(accountId); #elif SE_DG _login_dy(accountId); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public string getAccountId() { try { #if UNITY_EDITOR return""; #elif SE_WG return _getAccountId_wx(); #elif SE_DG return _getAccountId_dy(); #endif } catch (Exception e) { Console.WriteLine(e); throw; } return ""; } public void logout() { try { #if UNITY_EDITOR return; #elif SE_WG _logout_wx(); #elif SE_DG _logout_dy(); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void setSuperProperties(Dictionary properties = null) { try { string jsonString = JsonConvert.SerializeObject(properties); #if UNITY_EDITOR return; #elif SE_WG _setSuperProperties_wx(jsonString); #elif SE_DG _setSuperProperties_dy(jsonString); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void unsetSuperProperty(string key) { try { #if UNITY_EDITOR return; #elif SE_WG _unsetSuperProperty_wx(key); #elif SE_DG _unsetSuperProperty_dy(key); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void clearSuperProperties() { try { #if UNITY_EDITOR return; #elif SE_WG _clearSuperProperties_wx(); #elif SE_DG _clearSuperProperties_dy(); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void setPresetEvent(PresetEventType eventType, Dictionary properties = null) { try { string jsonString = JsonConvert.SerializeObject(properties); #if UNITY_EDITOR return; #elif SE_WG _setPresetEvent_wx(eventType.ToString(), jsonString); #elif SE_DG _setPresetEvent_dy(eventType.ToString(), jsonString); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void setChannel(string channel) { try { #if UNITY_EDITOR return; #elif SE_WG _setChannel_wx(channel); #elif SE_DG _setChannel_dy(channel); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void setReferrerTitle(string referrer_title) { try { #if UNITY_EDITOR return; #elif SE_WG _setReferrerTitle_wx(referrer_title); #elif SE_DG _setReferrerTitle_dy(referrer_title); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void setXcxPageTitle(string page_title) { try { #if UNITY_EDITOR return; #elif SE_WG _setXcxPageTitle_wx(page_title); #elif SE_DG _setXcxPageTitle_dy(page_title); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackAdImpression(AdImpressionData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackAdImpression_wx(json); #elif SE_DG _trackAdImpression_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackAdClick(AdClickData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackAdClick_wx(json); #elif SE_DG _trackAdClick_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackIAP(IAPData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackIAP_wx(json); #elif SE_DG _trackIAP_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackAppAttr(MpAttrData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackAppAttr_wx(json); #elif SE_DG _trackAppAttr_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackOrder(OrderData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackOrder_wx(json); #elif SE_DG _trackOrder_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackRegister(RegisterData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackRegister_wx(json); #elif SE_DG _trackRegister_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackLogin(LoginData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackLogin_wx(json); #elif SE_DG _trackLogin_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackReActive(ReActiveData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackReActive_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackAddToWishlist(AddToWishlistData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackAddToWishlist_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackShare(ShareData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackShare_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackCreateRole(CreateRoleData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackCreateRole_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackTutorialFinish(TutorialFinishData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackTutorialFinish_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackUpdateLevel(UpdateLevelData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackUpdateLevel_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackViewContentMall(ViewContentMallData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackViewContentMall_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void trackViewContentActivity(ViewContentActivitData data) { try { string json = JsonConvert.SerializeObject(data, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _trackViewContentActivity_wx(json); #elif SE_DG Debug.Log("only wechat can use"); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void track(string eventname, Dictionary data = null) { try { string json = JsonConvert.SerializeObject(data); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _track_wx(eventname, json); #elif SE_DG _track_dy(eventname, json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void eventStart(string eventname) { try { #if UNITY_EDITOR return; #elif SE_WG _eventStart_wx(eventname); #elif SE_DG _eventStart_dy(eventname); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void eventFinish(string eventname, Dictionary data = null) { try { string json = JsonConvert.SerializeObject(data); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _eventFinish_wx(eventname, json); #elif SE_DG _eventFinish_dy(eventname, json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void userInit(Dictionary data) { try { string json = JsonConvert.SerializeObject(data); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _userInit_wx(json); #elif SE_DG _userInit_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void userUpdate(Dictionary data) { try { string json = JsonConvert.SerializeObject(data); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _userUpdate_wx(json); #elif SE_DG _userUpdate_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void userAdd(Dictionary data) { try { string json = JsonConvert.SerializeObject(data); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _userAdd_wx(json); #elif SE_DG _userAdd_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void userAppend(Dictionary data) { try { string json = JsonConvert.SerializeObject(data); if (debug) Debug.Log("JSON: " + json); #if UNITY_EDITOR return; #elif SE_WG _userAppend_wx(json); #elif SE_DG _userAppend_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void userUnset(List list) { try { string json = JsonConvert.SerializeObject(list); #if UNITY_EDITOR return; #elif SE_WG _userUnset_wx(json); #elif SE_DG _userUnset_dy(json); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void userDelete(UserDeleteType type) { try { #if UNITY_EDITOR return; #elif SE_WG _userDelete_wx(type.ToString()); #elif SE_DG _userDelete_dy(type.ToString()); #endif } catch (Exception e) { Console.WriteLine(e); throw; } } public void getAttribution(AttributionCalllback calllback) { try { getattributioncallback = calllback; #if UNITY_EDITOR return; #elif SE_WG _getAttribution_wx(); #elif SE_DG _getAttribution_dy(); #endif } catch (Exception e) { Debug.LogError("getAttribution:" + e); throw; } } public void setOnAttributionListener(AttributionCalllback calllback) { try { setattributioncallback = calllback; #if UNITY_EDITOR return; #elif SE_WG _setOnAttributionListener_wx(); #elif SE_DG _setOnAttributionListener_dy(); #endif } catch (Exception e) { Debug.LogError("setOnAttributionListener:" + e); throw; } } public void addInitReadyCallback(InitReadyCalllBack calllBack) { try { initReadyCalllBack += calllBack; #if UNITY_EDITOR return; #elif SE_DG||SE_WG _ready(); #endif } catch (Exception e) { Debug.LogError("initReady:" + e); throw; } } public void removeInitReadyCallback(InitReadyCalllBack callback) { initReadyCalllBack -= callback; } public void readyFun() { initReadyCalllBack?.Invoke(); } private void setOnAttributionListenerFun(string result) { if (debug) Debug.Log("SetOnAttributionFun : " + result); setattributioncallback?.Invoke(result); } private void getAttributionFun(string result) { if (debug) Debug.Log("GetOnAttributionFun : " + result); getattributioncallback?.Invoke(result); } public void asyncFetchRemoteConfigFun(string result) { try { Async asyncFetch = JsonConvert.DeserializeObject(result); if (asyncFetch == null) return; if (asyncFetchRemoteConfigCallBacks.ContainsKey(asyncFetch.key)) { asyncFetchRemoteConfigCallBacks[asyncFetch.key]?.Invoke(asyncFetch.value); asyncFetchRemoteConfigCallBacks.Remove(asyncFetch.key); } else { // 键不存在 Debug.Log("未赋值"); } } catch (Exception e) { Console.WriteLine(e); throw; } } private void getDistinctFun(string result) { try { Distinct distinct = JsonUtility.FromJson(result); distinctCalllback?.Invoke(distinct); } catch (Exception e) { Console.WriteLine(e); throw; } } } [System.Serializable] public class Async { public string key; public object value; } [System.Serializable] public class InitParams { public string userId; public string appKey; public string unionid; public string openid; #if SE_DG public string anonymous_openid; #endif public InitConfig config; } [System.Serializable] public class InitConfig { public bool debugModel; public bool logEnabled; public RemoteConfig remoteConfig; public bool isInitTencentAdvertisingGameSDK; public int reportingToTencentSdk = 3; public TencentSDKInitParams tencentAdvertisingGameSDKInitParams; } public class TencentSDKInitParams { public int user_action_set_id; public string secret_key; public string appid; } [System.Serializable] public class RemoteConfig { public int pollingInterval; public bool enable; public int mergeType; public Dictionary customIDProperties; public Dictionary customIDEventProperties; public Dictionary customIDUserProperties; public long requestTimeout; } [System.Serializable] public class DefaultConfig { public string name; public int type; public object value; } [System.Serializable] public class AdImpressionData { public string adNetworkPlatform; public int adType; public string adNetworkAppID; public string adId; public string mediationPlatform; public double ecpm; public string currency; public bool rendered; public Dictionary customProperties; } [System.Serializable] public class AdClickData { public string adNetworkPlatform; public int adType; public string adId; public string mediationPlatform; public Dictionary customProperties; } [System.Serializable] public class IAPData { public int reportingToTencentSdk; public string orderId; public double payAmount; public string currencyType; public string payType; public string productID; public string productName; public int productCount; public int payStatus; public string failReason; public Dictionary customProperties; } [System.Serializable] public class MpAttrData { public string adNetwork; public string subChannel; public string adAccountID; public string adAccountName; public string adCampaignID; public string adCampaignName; public string adOfferID; public string adOfferName; public string adCreativeID; public string adCreativeName; public string attributionPlatform; public Dictionary customProperties; } [System.Serializable] public class OrderData { public string orderId; public double payAmount; public string currencyType; public string payType; public string status; public Dictionary customProperties; } [System.Serializable] public class LoginData { public string loginType; public string loginStatus; public Dictionary customProperties; } [System.Serializable] public class RegisterData { public int reportingToTencentSdk; public string regType; public string registerStatus; public Dictionary customProperties; } [System.Serializable] public class ReActiveData { public int reportingToTencentSdk; public int backFlowDay; public Dictionary customProperties; } [System.Serializable] public class AddToWishlistData { public int reportingToTencentSdk; public string addToWishlistType; public Dictionary customProperties; } [System.Serializable] public class ShareData { public int reportingToTencentSdk; public string mpShareTarget; public Dictionary customProperties; } [System.Serializable] public class CreateRoleData { public int reportingToTencentSdk; public string mpRoleName; } [System.Serializable] public class TutorialFinishData { public int reportingToTencentSdk; } [System.Serializable] public class UpdateLevelData { public int reportingToTencentSdk; public int beforeUpgrade; public int afterUpgrade; public Dictionary customProperties; } [System.Serializable] public class ViewContentMallData { public int reportingToTencentSdk; public Dictionary customProperties; } [System.Serializable] public class ViewContentActivitData { public int reportingToTencentSdk; public Dictionary customProperties; } [System.Serializable] public class Distinct { public string distinct_id; public string distinct_id_type; } public enum PresetEventType { mpInstall, mpStart, mpEnd, all } public enum UserDeleteType { userDeleteByAccountId, userDeleteByVisitorId } }