在Unity中进行断点调试

本文介绍如何在Unity中使用VisualStudio2019进行断点调试。首先需要正确配置VisualStudio,选择安装VisualStudioToolsforUnity组件。配置完成后,可以在VisualStudio中附加到Unity进程,设置断点并调试复杂程序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Unity中进行断点调试

问题

我们在进行Unity开发时需要调试,有的时候Debug能够满足需求,但是在真正复杂的程序Debug就满足不了,此时就需要用到断点调试。我们在安装Uinty的时候,一般会选择Visual Studio作为开发环境,但是很多时候安装完Visual Studio后是无法联合Unity进行断点调试的,Visual Studio的显示状态是启动,如下图
在这里插入图片描述
此时点击调试也没有能够在Unity中使用的选项,如下图(请忽略红色,这是我修改好的),此时就需要对Visual Studio进行修改。
在这里插入图片描述

以下针对Unity与Visual Studio 2019进行说明,其他版本请参考。

修改

  1. 关闭Unity和Visual Studio ,通过开始菜单找到Visual Studio的安装程序并启动
    在这里插入图片描述
  2. 启动后选择修改
    在这里插入图片描述
  3. 选择单个组件,再勾选Visual Studio Tools for Unity,再点击右下角修改
    在这里插入图片描述
  4. 代修改完成后就可以使用了

使用

此时状态就变成了附加到Unity,如下图
在这里插入图片描述
有时也不显示附加到Unity(比较少见),此时点击调试,打开下拉菜单,如下图,选择附加到Unity程序
在这里插入图片描述
此时就可以进行断点调试了,先选定断定位置(这个不用说明吧),然后点击绿色三角附加到Unity程序,然后在Unity编辑器中运行Unity程序,最后再到Visual Studio按快捷键进行断点调试就好了。

请看安装说明安装 很难的的工具 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、付费专栏及课程。

余额充值