Visual Studio Debugger not attaching to Unity

2020-02-23 08:50发布

I'm having issues getting Visual Studio's debugger to attach to Unity - editing and compiling scripts inside VS is working fine - however, when clicking "Attach to Unity" or "Attach to Unity and Play", the code compiles but nothing else happens. If all the builds are up-to-date then the button does nothing at all. I can manually start the game inside Unity and it runs the up-to-date code, but it is not attached to the VS debugger.

I have Unity 5.3.5, Visual Studio Tools for Unity 2.2.0.0 and Visual Studio Community 2015 installed on my PC. All of the Unity tools appear inside Visual Studio (Attach To Unity, etc).

Going Tools > Attach To Unity Debugger inside VS brings up a correct list of open instances of Unity editor, but selecting one doesn't attach to it. As suggested here I've attempted using 127.0.0.1 as the IP endpoint, but that still didn't work. I've allowed both Unity and VS through the firewall settings, to no avail.

Unity's Help > About also display's the Visual Studio Tools For Unity version number, so it is aware of the plugin's existence.

I loaded up VS via devenv.exe /log to see if anything weird was happening - the log looked fine and that Unity Tools was loaded up properly. (The log is here if that is of any use.)

I've done a repair reinstall on VS, Unity and VS Tools for Unity, which was long and arduous, but changed nothing.

I'm going mad trying to get it to work - it's really frustrating to press "Attach To Unity" and see it do literally nothing, not even an error message. I feel like I must be missing something - any ideas / suggestions / solutions would be greatly appreciated

4条回答
甜甜的少女心
2楼-- · 2020-02-23 09:06

Two days thrown away trying to reinstall just EVERYTHING.... (PS: latest Xamarin "stable" update broke iOS debugging on iPhone via usb, just to let you know too....).

查看更多
三岁会撩人
3楼-- · 2020-02-23 09:21

This was killing me too. After going through everything installed in the last few days and uninstalling and reinstalling, I determined that the latest Xamarin broke VSTU integration. I even reverted to VSTU 2.1 to no avail.

Only uninstalling Xamarin allowed the debugger to attach to Unity.

So for now, we have to use either Xamarin or VSTU, but not both on the same machine if we want the VS debugger to attach to Unity.

查看更多
小情绪 Triste *
4楼-- · 2020-02-23 09:21

I had the same problem, except that the tool didn't print any unity process... Uninstalling Xamarin as well didn't help, and in fact I was just not able at all to attach unity throw the tool. (Attach process did worked, but no breakpoint in code can be reached).

In fact, it was because I renamed "Unity.exe" to Unity "5.3.4f1.exe".

Visual Studio Tools for Unity need to attach to the process Unity, and no other name can be handle for now.

查看更多
祖国的老花朵
5楼-- · 2020-02-23 09:24

This is indeed a compatibility issue between VSTU and XamarinVS. We worked with Xamarin and we already fixed this in our master.

We will release a new VSTU version with the fix and additional features shortly.

Regards Sebastien Lebreton [MSFT]

查看更多
登录 后发表回答