I'm using Visual Studio with Unity. In general in VS I can simply click "Attach to Unity" and it will build the solution and indeed attach to Unity.
Sometimes, however, a project loses the "ability" to do so, what means that suddenly clicking the button will only build the solution and not attach to Unity.
I really would like to know what's happening there as I'm not aware of doing anything that could result in such a behaviour.
There are some parameters that might have an effect:
Check that Visual Studio is set as your external script editor in Unity using Edit / Preferences / External Tools . Depending on your Unity version: Check that the Visual Studio plugin is installed in Unity. Help / About should display a message like Microsoft Visual Studio Tools for Unity is enabled at the bottom.
In Visual Studio for Mac, on the top menu, choose Run > Attach to Process. In the Attach to Process dialog, select Unity Debugger option in the Debugger drop-down menu at the bottom. Select a Unity instance from the list and click the Attach button.
Unity has built-in support for opening scripts in Visual Studio Code as an external script editor on Windows and macOS. Unity will detect when Visual Studio Code is selected as an external script editor and pass the correct arguments to it when opening scripts from Unity. Unity will also set up a default .
Here's how i fixed it. The Attach Unity Debugger will not show up unless you have installed the "Game Development with Unity" addon by going to youre menu item Tools / Get Tools and Features. From the Visual Studio Installer under workloads you'll see the option to turn on 'Game Development with Unity'.
I'm using Visual Studio with Unity. In general in VS I can simply click "Attach to Unity" and it will build the solution and indeed attach to Unity. Sometimes, however, a project loses the "ability" to do so, what means that suddenly clicking the button will only build the solution and not attach to Unity.
I can build the game from Unity without errors, build the entire solution in Visual Studio without errors, but when I try to attach, I get "The operation could not be completed. Unspecified error". This is with Unity 2018.2.0f2, Visual Studio 2017 v15.7.5, and VSTU v3.7.0.1.
If you are targeting the legacy runtime, Visual Studio Tools for Unity will use information from the DLL and PDB to create a DLL.MDB file, which is the debug symbol format used by the legacy Unity scripting engine.
For me (Unity 2020.x and VS19) this happens quite often. Simply close VS and in Unity > Edit > Preferences > External Tools
Click on "Regenerate project files" (you don't need to check anything else, just click the button)
Start VS again, and it should work as normal.
For me "Attach to Unity" disappeared from the toolbar.
But I still have a button in Debug -> Attach Unity Debugger
Hope it will help someone.
Visual Studio Community 2019 16.7
Unity 2020.1.2f1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With