源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

272 行
7.1 KiB

  1. # Bugly Unity Plugin Guide
  2. ------
  3. # **Bugly Unity Plugin**
  4. > * Modified: **2015.03.28**
  5. > * Unity Plugin Version: **1.4.3**
  6. > * iOS SDK Version: **1.4.8+**
  7. > * Android SDK Version: **1.2.9+**
  8. ------
  9. ## Package Contents
  10. ### Bugly Unity Plugin Package Contains
  11. > * BuglySDK
  12. > * Editor
  13. > * Android
  14. > * iOS
  15. - `Bugly.framework`
  16. - `libBuglyBridge.a`
  17. >
  18. > * Plugins
  19. > * Android
  20. > > libs
  21. > > > `buglyagent.jar`
  22. >
  23. > * BuglyPlugins
  24. > > `BuglyAgent.cs`
  25. > >
  26. > > `BuglyInit.cs`
  27. >
  28. > * Samples
  29. >
  30. > **Notes:**
  31. >
  32. > - `BuglyAgent.cs` - Script of interface method
  33. >
  34. > - `BuglyInit.cs` - Script binding the gameobject to initialize the sdk
  35. >
  36. > - `Editor` - Scripts to update the xcode project
  37. >
  38. > - `Bugly.framework` - The sdk for iOS, you could replace it by the latest version
  39. >
  40. > - Samples - Sample project of using Bugly Unity Plugin
  41. >
  42. ------
  43. ## Getting Started with Bugly Unity Plugin
  44. ### Download
  45. You can go to the [Bugly](http://bugly.qq.com/whitebook) download the unity plugin and native sdk for iOS or Android.
  46. * Download the Bugly Unity Plugin
  47. >
  48. * Download the iOS SDK
  49. >
  50. * Download the Android SDK
  51. >
  52. ### Install
  53. * Double click the `bugly_unity_*.unitypackage` file and import the scripts into the unity project.
  54. > * Select Assets/Plugins into the unity project
  55. > * Copy the Android SDK into the unity project
  56. >
  57. * Call the interface method in the first loaded script of the project, details see the `Samples`
  58. > * Init the sdk in the first loaded script as following
  59. >
  60. > ```
  61. > BuglyAgent.InitWithAppId("You App Id")
  62. > ```
  63. >
  64. * Copy iOS SDK (`Bugly.framework`) into the associated Xcode project and add some dependencies libraries.
  65. > * Drag the **Bugly.framework** into the Xcode project and select the copy trigger
  66. > * Open the Xcode project configuration window and select the **Build Phases** tab, add libraries in **Link Binary With Libraries** as following:
  67. > > Security.framework
  68. > >
  69. > > libz.dylib
  70. > >
  71. ### Samples
  72. ```c
  73. public class Welcome : MonoBehaviour {
  74. void InitBuglySDK(){
  75. // enable debug log, please set FALSE in Release version.
  76. BuglyAgent.ConfigDebugMode (true);
  77. #if UNITY_IPHONE || UNITY_IOS
  78. BuglyAgent.InitWithAppId ("Your App ID");
  79. #elif UNITY_ANDROID
  80. BuglyAgent.InitWithAppId ("Your App ID");
  81. #endif
  82. // 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),
  83. // please call this method to enable c# exception handler only.
  84. BuglyAgent.EnableExceptionHandler ();
  85. }
  86. // Use this for initialization
  87. void Start () {
  88. InitBuglySDK();
  89. }
  90. }
  91. ```
  92. ------
  93. ## APIs
  94. - **BuglyAgent.InitWithAppId(string)**
  95. > 初始化Bugly,传入Bugly网站注册获得的App ID。
  96. >
  97. > 启用native code(Obj-C、C/C++、Java)异常、C#异常捕获上报,如果你已经在相应的iOS或Android工程中初始化Bugly,那么你只需调用`BuglyAgent.EnableExceptionHandler`开启C#异常捕获上报即可。
  98. >
  99. - **BuglyAgent.EnableExceptionHandler()**
  100. > 启动C#异常日志捕获上报,默认自动上报级别LogError,那么LogError、LogException的异常日志都会自动捕获上报。
  101. >
  102. > 日志级别定义参考LogSeverity : {LogDebug、LogWarning、LogAssert、LogError、LogException}
  103. >
  104. - **BuglyAgent.RegisterLogCallback(BuglyAgent.LogCallbackDelegate)**
  105. > 注册LogCallbackDelegate回调方法, 处理系统的日志。
  106. >
  107. > 如果你的应用需要调用Application.RegisterLogCallback(LogCallback)等注册日志回调,你可以使用此方法进行替换。
  108. >
  109. - **BuglyAgent.ConfigAutoReportLogLevel(LogSeverity)**
  110. > 设置自动上报日志信息的级别,默认LogError,则>=LogError的日志都会自动捕获上报。
  111. >
  112. > 日志级别的定义有LogDebug、LogWarning、LogAssert、LogError、LogException等
  113. >
  114. - **BuglyAgent.ReportException (System.Exception, string)**
  115. > 上报已捕获C#异常,输入参数异常对象,附加描述信息
  116. >
  117. - **BuglyAgent.ReportException (string, string, string)**
  118. > 上报自定义错误信息,输入错误名称、错误原因、错误堆栈等信息
  119. >
  120. - **BuglyAgent.SetUserId (string)**
  121. > 设置用户标识,如果不设置,默认为10000 。
  122. >
  123. > 在初始化之后调用
  124. >
  125. - **BuglyAgent.ConfigDebugMode (bool)**
  126. > 开启本地调试日志打印,默认关闭
  127. >
  128. > 注意:在发布版本中请务必关闭调试日志打印功能
  129. >
  130. - **BuglyAgent.ConfigDefault (string, string, string, long)**
  131. > 修改应用默认配置信息:渠道号、版本、用户标识等。
  132. >
  133. > 在初始化之前调用
  134. >
  135. > 渠道号默认值为空,
  136. >
  137. > 版本默认值
  138. >
  139. > - Android应用默认读取AndroidManifest.xml中的android:versionName
  140. > - iOS应用默认读取Info.plist文件中CFBundleShortVersionString和CFBundleVersion,拼接为CFBundleShortVersionString(CFBundleVersion)格式,例如1.0.1(10)
  141. >
  142. > 用户标识默认值10000
  143. >
  144. - **BuglyAgent.ConfigAutoQuitApplication (bool)**
  145. > 配置是否在捕获上报C#异常信息后就立即退出应用,避免后续产生更多非预期的C#的异常。
  146. >
  147. > 在初始化之前调用
  148. >
  149. ------
  150. ## Change Logs
  151. #### Change Log (2015/08/06):
  152. * Modify the interface class to **`BuglyAgent.cs`**
  153. * Modify initialize method to **`BuglyAgent.InitWithAppId`**
  154. * Add **`BuglyAgent.LogCallbackDelegate`** to replace register `Application.LogCallback`
  155. * Add interface **`BuglyAgent.ReportException(Exception, string)`** to report customized c# exception
  156. * Add interface **`BuglyAgent.ReportException (string, string, string)`** to report customized error
  157. #### Change Log (2015/06/08):
  158. * Add config to exit the application after catch c# exception>
  159. * Add Editor settings to update the xcode project
  160. * Fix the problem about the init method
  161. #### Change Log (2015/04/21):
  162. * Add log callback method `LogCallbackDelegate`
  163. #### Change Log (2015/03/15):
  164. * Modify the interface of `IBugly`
  165. * Fix the bugs
  166. #### Change Log (2015/01/21):
  167. * Add method `EnableExceptionHandler`
  168. * Modify the interface of the SDK (Android & iOS)
  169. #### Change Log (2014/12/29):
  170. * iOS SDK change the interface
  171. * Modify the plugin interface method
  172. #### Change Log (2014/12/12):
  173. * Android SDK change the interface
  174. * Add method `HandleException`
  175. #### Change Log (2014/11/20):
  176. * Android SDK integrated
  177. * Public class method `BuglyUnity` exposed
  178. #### Change Log (2014/11/18):
  179. * iOS SDK integrated
  180. ------
  181. ## FAQ
  182. 1. 初始化SDK后,为什么仍然无法捕获上报C#异常?
  183. > 答: 如果无法捕获上报C#异常,可以检查下面两项排查:
  184. > 1. 检查是否有其他存在注册Application.RegisterLogCallback(LogCallback)的逻辑,由于系统默认的LogCallback是单播实现,
  185. > 所以只能维持一个回调实例,你可以调用BuglyAgent.RegisterLogCallback(BuglyAgent.LogCallbackDelegate)方法来替代日志回调的注册。
  186. >
  187. > 2. 检查对应平台的SDK组件是否已集成到项目。
  188. >
  189. 2. 为什么发生C#异常后,应用直接崩溃?
  190. > 答: 如果遇到此场景,你可以把脚本中调用的InitWithAppId方法使用EnableExceptionHandler替代,并在对应的Android或iOS工程中初始化SDK的组件。
  191. ------
  192. ##Contact US
  193. * Web: **http://bugly.qq.com/contact**
  194. * Email: **bugly@tencent.com**
  195. * QQ: **800014972**
  196. * WeChat: **Bugly**