Unity3D 调试 断点

一、设置编辑器为MonoDevelop
     先把脚本编辑器指定为MonoDevelop了。
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
二、断点调试
具体的连接方法有2种:
第一种,先把当前场景保存一下,然后关掉Unity。回到MonoDevelop,按F5或者点击Debug按钮。
 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
这样,MonoDevelop会打开一个新的Unity3D界面,这时候连接完成了。
 这种方法要关掉Unity,不好使,建议第二种!!!
 
第二种方法,无需关掉Unity,在MonoDevelop的Run菜单下选择Attach to Process 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
 
然后选择Unity的进程,点击Attach按钮。 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
 这时候,MonoDevelop就连接上了Unity了。
然后就可以在 MonoDevelop启动debug,再去Unity3D里面操作,就可以进入相应的断点了!!

具体做法如下(vs熟练者可忽略):
当连接好了Unity3D之后,右边的调试按钮就变成可用了,我们把视窗显示选择Debug。
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
debug模式脚本下面的位置会多出两个窗口。 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
回到Unity,点击运行按钮,会看到刚才的脚本已经运行了。里面有两个按钮。 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
回到MonoDevelop,在脚本里面我们打一个断点(在行号左边点一下) 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
 然后回到Unity里面,点击第一个按钮“add”。这时候断点起作用了,程序会暂停,MonoDevelop跳到断点的行。
 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
留意看下面debug的Locals信息,会看到当前状态下的变量i和sum的值。 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
使用调试按钮,让程序单步的运行
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
我们看到了当前的变量i和sum的实际变化情况。
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
 
到这里,断点调试已经完成。
 
调试完之后,我建议最好把MonoDevelop和Unity3D的连接断开。假如你不断开的话,Unity会一直处于很卡的状态。
 
断开的方法也是有几种了,首先对应Debug按钮有一个断开的按钮,可以直接点击断开。 
 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
或者我们可以把刚才附加的进程Detach掉。 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
 
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵
再或者,我们可以点击这个插头按钮,把Debugger 断开。
Unity3D的断点调试功能 - 阿赵 - 有爪的小羔羊阿赵

         这两种方法连接Unity,我建议还是使用第二种附加进程的方式吧。毕竟你不可能每次调试都要关掉一次Unity然后再从MonoDevelop打开一次Unity。所以,编写脚本的时候,把连接Detach掉,等需要调试的时候,再把进程Attach上去,进行调试就行了。

转载自:http://liweizhaolili.blog.163.com/blog/static/162307442013214485190/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
请看安装说明安装 很难的的工具 1. If you have previously installed UnityVS uninstall it now, run ccleaner to remove any left over files & registry keys and reboot. 2. Run UnityVS 2012.msi to install UnityVS 3. Run "make Dir.bat" as ADMINISTRATOR, if you see any errors then make sure you have admin rights and run it again. 4. Right click "copy rhino.bat" and choose edit to open it in notepad 5. replace PATH_TO_THIS_DIRECTORY with the directory which you extracted the .bat and "Rhino.Licensing.dll" to. You should end up with something that looks like this 'copy "D:\extracted\Rhino.Licensing.dll" "%SystemRoot%\assembly\GAC_MSIL\Rhino.Licensing\1.2.0.0__0b3305902db7183f"' 6. Save the edit .bat and run it as ADMINISTRATOR, if you get any errors check the file again and make sure it saved correctly. 7. Navigate to "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\SyntaxTree\UnityVS" and DELETE the "Rhino.Licensing.dll" File (it should ask you for admin rights to do this) 8. Now move (Cut & paste) the "log4net.dll" file from the current UnityVS Directory to the Visual Studio IDE directory (Go up 3 Directories - "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE") 9. Launch Visual Studio 2012 (If you get any errors from visual studio at this point or after make sure you've followed every step correctly, if you have uninstall UnityVs, uninstall visual studio 2012, run ccleaner for both temp files and the registry then reboot and start again) 10. It should now prompt you for your key, open up the key.txt extracted earlier and copy the contents into the box, it should now enable the OK button, click that and you're done! 11.If you still have errors after installing the crack try changing "1.2.0.0__0b3305902db7183f" to "1.2.0.0__49e34be443e62e2a" in both the make dir.bat and copy rhino.bat files and run them again.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值