源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
4.0 KiB

  1. // ----------------------------------------
  2. //
  3. // BuglyInit.cs
  4. //
  5. // Author:
  6. // Yeelik, <bugly@tencent.com>
  7. //
  8. // Copyright (c) 2015 Bugly, Tencent. All rights reserved.
  9. //
  10. // ----------------------------------------
  11. //
  12. using UnityEngine;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. public class BuglyInit
  16. {
  17. /// <summary>
  18. /// Your Bugly App ID. Every app has a special identifier that allows Bugly to associate error monitoring data with your app.
  19. /// Your App ID can be found on the "Setting" page of the app you are trying to monitor.
  20. /// </summary>
  21. /// <example>A real App ID looks like this: 90000xxxx</example>
  22. //#if UNITY_IPHONE || UNITY_IOS
  23. // private const string BuglyAppID = "YOUR APP ID GOES HERE";
  24. //#elif UNITY_ANDROID
  25. // private const string BuglyAppID = "728290c0c0";
  26. //#else
  27. // private const string BuglyAppID = "";
  28. //#endif
  29. public static void Init ()
  30. {
  31. // Enable the debug log print
  32. BuglyAgent.ConfigDebugMode (true);
  33. // Config default channel, version, user
  34. //BuglyAgent.ConfigDefault (null, null, null, 0);
  35. // Config auto report log level, default is LogSeverity.LogError, so the LogError, LogException log will auto report
  36. BuglyAgent.ConfigAutoReportLogLevel (LogSeverity.LogWarning);
  37. // Config auto quit the application make sure only the first one c# exception log will be report, please don't set TRUE if you do not known what are you doing.
  38. //BuglyAgent.ConfigAutoQuitApplication (false);
  39. // If you need register Application.RegisterLogCallback(LogCallback), you can replace it with this method to make sure your function is ok.
  40. //BuglyAgent.RegisterLogCallback (null);
  41. // Init the bugly sdk and enable the c# exception handler.
  42. //Unity�е�libmono.so�������źŴ�����Ϊ�˱��⴦����ͻlibBugly.so���ر��źŴ����������޷��ϱ�Native�쳣(SIGSEGV,SIGABRT,SIGFPE,SIGBUS)
  43. //Ҫ�����������⣬����Ҫ�ڵ�����Android��Ŀ�У���Activity.onCreate()�г�ʼ��Bugly(CrashReport.initCrashReport())
  44. //BuglyAgent.InitWithAppId (BuglyAppID);
  45. // TODO Required. If you do not need call 'InitWithAppId(string)' to initialize the sdk(may be you has initialized the sdk it associated Android or iOS project),
  46. // please call this method to enable c# exception handler only.
  47. BuglyAgent.EnableExceptionHandler ();
  48. // TODO NOT Required. If you need to report extra data with exception, you can set the extra handler
  49. //BuglyAgent.SetLogCallbackExtrasHandler (MyLogCallbackExtrasHandler);
  50. }
  51. // Extra data handler to packet data and report them with exception.
  52. // Please do not do hard work in this handler
  53. static Dictionary<string, string> MyLogCallbackExtrasHandler ()
  54. {
  55. // TODO Test log, please do not copy it
  56. BuglyAgent.PrintLog (LogSeverity.Log, "extra handler");
  57. // TODO Sample code, please do not copy it
  58. Dictionary<string, string> extras = new Dictionary<string, string> ();
  59. extras.Add ("ScreenSolution", string.Format ("{0}x{1}", Screen.width, Screen.height));
  60. extras.Add ("deviceModel", SystemInfo.deviceModel);
  61. extras.Add ("deviceName", SystemInfo.deviceName);
  62. extras.Add ("deviceType", SystemInfo.deviceType.ToString ());
  63. extras.Add ("deviceUId", SystemInfo.deviceUniqueIdentifier);
  64. extras.Add ("gDId", string.Format ("{0}", SystemInfo.graphicsDeviceID));
  65. extras.Add ("gDName", SystemInfo.graphicsDeviceName);
  66. extras.Add ("gDVdr", SystemInfo.graphicsDeviceVendor);
  67. extras.Add ("gDVer", SystemInfo.graphicsDeviceVersion);
  68. extras.Add ("gDVdrID", string.Format ("{0}", SystemInfo.graphicsDeviceVendorID));
  69. extras.Add ("graphicsMemorySize", string.Format ("{0}", SystemInfo.graphicsMemorySize));
  70. extras.Add ("systemMemorySize", string.Format ("{0}", SystemInfo.systemMemorySize));
  71. extras.Add ("UnityVersion", Application.unityVersion);
  72. BuglyAgent.PrintLog (LogSeverity.LogInfo, "Package extra data");
  73. return extras;
  74. }
  75. }