unity3d 官方文档的调试方法

之前从网上看到一个调试方法的版本,也能用,但是在一些情况下不行。
比如,我经常在工程中用到sqlite数据库,用网上流传的方法,需要在mono里面编译代码。如果是unity3d自己编译代码是没有任何问题的,但是mono会提示程序集什么的没有引用。这个问题很头疼。
看了官方的版本,试了一下,是没有问题的。
这里窃取一下别人翻译的,翻译中有不少错误的地方,有时间给他改正过来。

调试器 Debugger

Date:2012-03-28 09:09

The Unity Debugger lets you inspect your code at runtime. For example, it can help you determine when a function is called and with which values. Furthermore, it allows you to look at the value of scripts' variables at a given time while running your game. You can locate bugs or logic problems in your scripts by executing them step by step.

Unity调试,可以让你在运行时检查你的代码。例如,他可以帮助你确定某个函数被调用时的值。此外,他允许你在给定时间内同时运行你的游戏观看脚本中变量的值。你可以通过执行这些步骤在脚本中查找bug或逻辑问题。

Unity uses the MonoDevelop IDE to debug the scripts in your game. You can debug all the languages supported by the engine (JavaScript, C#, and Boo).

Unity使用MonoDevelop IDE来调试你游戏中的脚本。你可以调试引擎(Javascript,C#和Boo)支持的所有语言。

Note that the debugger has to load all your code and all symbols, so bear in mind that this can have a small impact on the performance of your game during execution. Typically, this overhead is not large enough to affect the game framerate.

请注意:调试器会加载你所有的代码和所有的符号,所以牢记,这在你游戏执行的过程中会对游戏的性能有一些小的影响。通常情况下,这种开销不足以大到影响游戏的帧率的。

MonoDevelop window debugging a script in unity.
MonoDevelop在Unity调试脚本的窗口。

Debugging in Unity.(在Unity中进行调试)

On Windows, users must choose to install MonoDevelop as part of the Unity installation (selected by default).

在Windows上,用户必须选择MonoDevelop作为(默认情况下选中)Unity安装的一部分。

  • If you haven't used MonoDevelop with your project before, synchronize your MonoDevelop project. This will open your project inside MonoDevelop. 
    如果在你的项目之前没有使用MonoDevelop,那么同步你的MonoDevelop项目。这将会在你的MonoDevelop中打开项目。

  • Set the necessary breakpoints on your scripts by clicking the lines that you want to analyze. 
    通过单击线在你的脚本中对你想要分析的地方设置必要的断点。

  • Launch Unity or your player. 启动Unity或者播放器
    • Unity: Ensure you have "Editor Attaching" checked in the Preferences window.(这里已经改了)
      Unity:确保在Preferences窗口中勾选了Editor Attaching。在External Tools下面
    • Players: Ensure that you have built your player with the "Development build" and "Allow script debugging" options enabled. For webplayers, additionally check that the development release channel setting is enabled on the player's context menu (right click on Windows or cmd-click on Mac OSX)
      播放器:确保在你编译播放器是启用了"Development Build" 和"Allow Script debugging"。
    • 这一步很重要啊!!!这里加个图片!这个不设置的话,不能调试的!!!
    • unity3d <wbr>官方文档的调试方法

  • Open your project in MonoDevelop. 
    在MonoDevelop中打开项目。
  • In MonoDevelop, click the Attach button in the toolbar, or choose Attach from the Run menu. 
    在MonoDevelop中单击工具栏中的附加按钮,或者选择Run菜单中的Attach。
  • From the dialog that appears, choose the item you wish to debug. 
    从出现的对话框中,选择你要调试的项目。
  • Notes: 注意:
    • Currently supported debugging targets: Unity editors, desktop standalone players, Android and iOS players 
      目前支持调试的目标:Unity编辑器,桌面独立播放器,Android和iOS播放器。
    • If your player is set not to run in the background (the default), you may need to focus your player for a few seconds in order for it to appear in the list. 
      如果播放器设置为不要在后台运行(默认),你可能需要关注你的播放器几秒,以便他出现在列表中。
    • Android and iOS players need to have networking enabled when script debugging is enabled. All players need to be on the same network subnet as the computer running MonoDevelop. 
      Android和iOS播放器在调试脚本时需要启用网络。所有的播放器都需要运行在MonoDevelop的计算机相同网络的子网中。

  • When you enter play mode, your script code will execute in the debugger. 
    当你按下播放模式,你的脚本代码将会在调试器中被执行。
  • When a breakpoint occurs, script execution will stop, and you will be able to use MonoDevelop to step over, into, and out of your script methods, inspect your variables, examine the call stack, etc.
    当断点发生时,停止执行脚本,你可以使用MonoDevelop去单步调试进出你脚本中的方法,检查变量,检查堆栈等。
    • Note: When you're done debugging a toplevel method (e.g. Update()), or you just want to jump to the next breakpoint, you will experience better debugger performance by using the Continue command instead of stepping out or over the end of your function. 
      注意:当你调试完一个顶层的方法(例如:Update()),或者你只想跳到下一个断点,你使用继续命令而不是跨出或超过函数会让你体会到更好的调试性能。

  • When you're done debugging, click the Detach or Stop buttons in the toolbar, or choose Detach or Stop from the Run menu. 
    当你完成调试是,在工具栏上单击"Detach"或"Stop"按钮,或者从Run菜单中选择 "Detach"或 "Stop"。

Hints. 提示

  • If you add a watch to the this object, you can inspect the internal values (position, scale, rotation...) of the GameObject to which the script is attached. 
    如果你添加对象到监视时,你可以检查该对象上脚本中内部的值(位置,缩放,旋转。。。)。

iOS remote debugging instructions
iOS远程调试的说明

In addition to the instructions described above, Unity iOS applications require some additional steps for successful debugging:

除以上所述介绍,Unity中的iOS应用程序要成功调试,还需要一些附加的步骤:

  1. Attach your iDevice to your WiFi network (the same requirement as for remote profiling). 
    将你的iDevice附加到你的WiFi网络(对于远程评测有相同的要求)。
  2. Hit build & run in the Unity editor. 
    在Unity编辑器中点击 build&run。
  3. When the application builds, installs& launches via Xcode, click Stop in Xcode. 
    当应用程序生成,安装以及通过Xcode启动,在Xcode中单击停止。
  4. Manually find & launch your application on your iDevice. (Note: if the application is launched via Xcode you won't be able to resume after reaching a breakpoint). 
    在iDevice中手动查找和启动应用程序。(注意:如果应用程序时候通过Xcode启动的,在到达断点之后你将无法恢复。)
  5. When the app is running on the device, switch to MonoDevelop and click on the attach icon in the debugging toolbar. Select your device from the available instances list (if there are several instances shown, then select the bottom one). 
    当应用程序运行在设备上时,切换到MonoDevelop,并单击调试工具栏中的连接图标。从可用实例列表中选择你的设备(如果显示有几个实例,选择底部的那个)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值