using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using System; namespace anysdk { public class AnySDKCrash { private static AnySDKCrash _instance; public static AnySDKCrash getInstance() { if( null == _instance ) { _instance = new AnySDKCrash(); } return _instance; } /** * set user identifier * * @param userInfo */ public void setUserIdentifier(string identifier) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) AnySDKCrash_nativeSetUserIdentifier (identifier); #else Debug.Log("This platform does not support!"); #endif } /** * The uploader captured in exception information * * @param message Set the custom information * @param exception The exception */ public void reportException(string message, string exception) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) AnySDKCrash_nativeReportException (message, exception); #else Debug.Log("This platform does not support!"); #endif } /** * customize logging * * @param String Custom log */ public void leaveBreadcrumb(string breadcrumb) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) AnySDKCrash_nativeLeaveBreadcrumb (breadcrumb); #else Debug.Log("This platform does not support!"); #endif } /** @brief Check function the plugin support or not */ public bool isFunctionSupported (string functionName) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) return AnySDKCrash_nativeIsFunctionSupported (functionName); #else Debug.Log("This platform does not support!"); return false; #endif } /** * set debugmode for plugin * */ [Obsolete("This interface is obsolete!",false)] public void setDebugMode(bool bDebug) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) AnySDKCrash_nativeSetDebugMode (bDebug); #else Debug.Log("This platform does not support!"); #endif } /** * Get Plugin version * * @return string */ public string getPluginVersion() { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) StringBuilder version = new StringBuilder(); version.Capacity = AnySDKUtil.MAX_CAPACITY_NUM; AnySDKCrash_nativeGetPluginVersion (version); return version.ToString(); #else Debug.Log("This platform does not support!"); return ""; #endif } /** * Get SDK version * * @return string */ public string getSDKVersion() { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) StringBuilder version = new StringBuilder(); version.Capacity = AnySDKUtil.MAX_CAPACITY_NUM; AnySDKCrash_nativeGetSDKVersion (version); return version.ToString(); #else Debug.Log("This platform does not support!"); return ""; #endif } /** *@brief methods for reflections *@param function name *@param AnySDKParam param *@return void */ public void callFuncWithParam(string functionName, AnySDKParam param) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) List list = new List (); list.Add (param); AnySDKCrash_nativeCallFuncWithParam(functionName, list.ToArray(),list.Count); #else Debug.Log("This platform does not support!"); #endif } /** *@brief methods for reflections *@param function name *@param List param *@return void */ public void callFuncWithParam(string functionName, List param = null) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) if (param == null) { AnySDKCrash_nativeCallFuncWithParam (functionName, null, 0); } else { AnySDKCrash_nativeCallFuncWithParam (functionName, param.ToArray (), param.Count); } #else Debug.Log("This platform does not support!"); #endif } /** *@brief methods for reflections *@param function name *@param AnySDKParam param *@return int */ public int callIntFuncWithParam(string functionName, AnySDKParam param) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) List list = new List (); list.Add (param); return AnySDKCrash_nativeCallIntFuncWithParam(functionName, list.ToArray(),list.Count); #else Debug.Log("This platform does not support!"); return -1; #endif } /** *@brief methods for reflections *@param function name *@param List param *@return int */ public int callIntFuncWithParam(string functionName, List param = null) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) if (param == null) { return AnySDKCrash_nativeCallIntFuncWithParam (functionName, null, 0); } else { return AnySDKCrash_nativeCallIntFuncWithParam (functionName, param.ToArray (), param.Count); } #else Debug.Log("This platform does not support!"); return -1; #endif } /** *@brief methods for reflections *@param function name *@param AnySDKParam param *@return float */ public float callFloatFuncWithParam(string functionName, AnySDKParam param) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) List list = new List (); list.Add (param); return AnySDKCrash_nativeCallFloatFuncWithParam(functionName, list.ToArray(),list.Count); #else Debug.Log("This platform does not support!"); return 0; #endif } /** *@brief methods for reflections *@param function name *@param List param *@return float */ public float callFloatFuncWithParam(string functionName, List param = null) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) if (param == null) { return AnySDKCrash_nativeCallFloatFuncWithParam (functionName, null, 0); } else { return AnySDKCrash_nativeCallFloatFuncWithParam (functionName, param.ToArray (), param.Count); } #else Debug.Log("This platform does not support!"); return 0; #endif } /** *@brief methods for reflections *@param function name *@param AnySDKParam param *@return string */ public bool callBoolFuncWithParam(string functionName, AnySDKParam param) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) List list = new List (); list.Add (param); return AnySDKCrash_nativeCallBoolFuncWithParam(functionName, list.ToArray(),list.Count); #else Debug.Log("This platform does not support!"); return false; #endif } /** *@brief methods for reflections *@param function name *@param List param *@return string */ public bool callBoolFuncWithParam(string functionName, List param = null) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) if (param == null) { return AnySDKCrash_nativeCallBoolFuncWithParam (functionName, null, 0); } else { return AnySDKCrash_nativeCallBoolFuncWithParam (functionName, param.ToArray (), param.Count); } #else Debug.Log("This platform does not support!"); return false; #endif } /** *@brief methods for reflections *@param function name *@param List param *@return string */ public string callStringFuncWithParam(string functionName, AnySDKParam param) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) List list = new List (); list.Add (param); StringBuilder value = new StringBuilder(); value.Capacity = AnySDKUtil.MAX_CAPACITY_NUM; AnySDKCrash_nativeCallStringFuncWithParam(functionName, list.ToArray(),list.Count,value); return value.ToString (); #else Debug.Log("This platform does not support!"); return ""; #endif } /** *@brief methods for reflections *@param function name *@param List param *@return string */ public string callStringFuncWithParam(string functionName, List param = null) { #if !UNITY_EDITOR &&( UNITY_ANDROID || UNITY_IOS) StringBuilder value = new StringBuilder(); value.Capacity = AnySDKUtil.MAX_CAPACITY_NUM; if (param == null) { AnySDKCrash_nativeCallStringFuncWithParam (functionName, null, 0,value); } else { AnySDKCrash_nativeCallStringFuncWithParam (functionName, param.ToArray (), param.Count,value); } return value.ToString (); #else Debug.Log("This platform does not support!"); return ""; #endif } [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeSetUserIdentifier(string identifier); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeReportException(string message, string exception); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeLeaveBreadcrumb(string breadcrumb); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern bool AnySDKCrash_nativeIsFunctionSupported(string functionName); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeSetDebugMode(bool bDebug); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeGetPluginVersion(StringBuilder version); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeGetSDKVersion(StringBuilder version); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeCallFuncWithParam(string functionName, AnySDKParam[] param,int count); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern int AnySDKCrash_nativeCallIntFuncWithParam(string functionName, AnySDKParam[] param,int count); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern float AnySDKCrash_nativeCallFloatFuncWithParam(string functionName, AnySDKParam[] param,int count); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern bool AnySDKCrash_nativeCallBoolFuncWithParam(string functionName, AnySDKParam[] param,int count); [DllImport(AnySDKUtil.ANYSDK_PLATFORM)] private static extern void AnySDKCrash_nativeCallStringFuncWithParam(string functionName, AnySDKParam[] param,int count,StringBuilder value); } }