Search Unity

Visual Studio 2019 - No 'Attach to Unity' debug option

Discussion in 'Code Editors & IDEs' started by andrewhoke, Apr 18, 2019.

  1. andrewhoke

    andrewhoke

    Joined:
    Aug 29, 2018
    Posts:
    22
    I installed VS2019 when it was released, and have been enjoying using the new features; however, I've had nonstop issues with the Unity development extension not working. No matter how I open VS, I don't get the attach option. I've tried running as admin and opening the project from the Editor in Assets->Open C# Project. I've been forced to revert to using VS2017 multiple times.

    For what it's worth, my project is currently stuck in 5.6.6f2 (yeah, I know), but I have seen this same issue when working in the QA version that is now in 2018.3.1f1.
     
  2. GeoffBot

    GeoffBot

    Joined:
    Oct 25, 2018
    Posts:
    3
    Using latest 2018 Unity build and had to revert to VS2017, all is well again. I'll wait until Unity bundles VS2019 before I try it again. Currently they still bundle 2017.
     
  3. andrewhoke

    andrewhoke

    Joined:
    Aug 29, 2018
    Posts:
    22
    Shame they would release the extension for VS2019 but not support it... :rolleyes:
     
  4. PabloAM

    PabloAM

    Joined:
    Dec 25, 2012
    Posts:
    35
    Please Unity release VS2019 support extension :)
     
    ROBYER1 likes this.
  5. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Hoping for an update on this so I can use VS 2019
     
  6. potterdev245

    potterdev245

    Joined:
    May 3, 2019
    Posts:
    1
    Until they do you can use:
    VS -> Debug -> Attach unity debugger -> double click project
     
  7. beefyt123

    beefyt123

    Joined:
    Mar 11, 2014
    Posts:
    1
    If you install the Visual Studio tools for Unity manually. The Attach to Unity option re-appears, and Intellisense is now offering unity functions for auto complete.

    1. Run Visual Studio Installer
    2. On the version of VS2019 you have installed click Modify
    3. At the top of the window navigate to Individual Components
    4. About 2/3 of the way down you will see a subtitle "Games and Graphics" make sure Visual Studio Tools for Unity is checked.
    5. In bottom right click install.
     
  8. andrewhoke

    andrewhoke

    Joined:
    Aug 29, 2018
    Posts:
    22
    This was always the case @beefyt123 and the manner in which I installed the VS Tools for Unity extension. I updated to Visual Studio 2019.1.1 today so we will see if that fixes the issue for good.
     
    lclemens likes this.
  9. furkan59

    furkan59

    Joined:
    Apr 18, 2017
    Posts:
    7
    it works for me you are my hero.
     
    vocasle likes this.
  10. BroncoBilli

    BroncoBilli

    Joined:
    Oct 8, 2017
    Posts:
    90
    Yes, the attach option works. Just today, I installed VS 2019 from scratch, ensured the VS Tools for Unity was checked, and installed Unity 2019.2.0... When I double click on the script file in unity, and it opens up VS 2019, there is no way to press the green Play button and start debugging. I MUST go and attach to unity. I don't know why Beefy's solution works, but it doesn't for me. There are a lot of options in Unity and in the VS Tools for Unity extension, I don't know what, if anything, modifying them would help with.
     
  11. andrewhoke

    andrewhoke

    Joined:
    Aug 29, 2018
    Posts:
    22
    I finally got my project upgraded to Unity 2018.3 and the attach option is working consistently. I imagine it was a compatibility issue with Unity 5.4.
     
  12. guodancoder

    guodancoder

    Joined:
    Dec 14, 2017
    Posts:
    4
    gooooooooooood
     
    rochal likes this.
  13. PetterL68

    PetterL68

    Joined:
    Jun 26, 2018
    Posts:
    23
    I had first problems with the connection to Unity. After reinstall the VS 2019 it work. But when i want to lookup some commands by using Ctr+ALT + M and Ctrl + H, i get a
    search option insted and if i let it search, it takes forever.


    Edit: Tried to revert back to 2017, but the same search box appears when trying to look up
    Mono commands with Ctrl+ALT +M and Ctrl +H.
    Looks like it is the search and replace box that appear.
     
    Last edited: Aug 25, 2019
  14. SamRock

    SamRock

    Joined:
    Sep 5, 2017
    Posts:
    250
    This fixed the issues! Thank you so much. After I installed VS2019, everytime I clicked on a Script it would open a new instance of VS. Now its all good!
     
  15. mcaldei01

    mcaldei01

    Joined:
    Dec 8, 2017
    Posts:
    12
    Be sure to follow the mentioned steps above first (Install Visual Studio Tools for Unity), but if still does not work (in my case with version 18.3.3f1), do this:

    - Exit Visual Studio if opened.
    - With Unity opened go to Edit\Preferences\External Tools (check you have VS 2019 as External Script Editor) and set Editor Attaching to FALSE and then exit Unity.
    - Open Unity and go again to Edit\Preferences\External Tools and set Editor Attaching to TRUE and exit Unity
    - Open Unity again and then Open Visual Studio.

    It should work now.
     
  16. cloakedninjas

    cloakedninjas

    Joined:
    Jul 20, 2018
    Posts:
    4
    Nope - at least not for Unity 2019.2.17f1 and VS 16.4.3
     
  17. jdmac020

    jdmac020

    Joined:
    Nov 16, 2016
    Posts:
    1
    This did the trick for me,
    VS2019 Community 16.4.3
    and
    Unity 2019.2.19f1
    . Thanks for reminding me about the external editor setting!!
     
    mcaldei01 likes this.
  18. TaNoX80

    TaNoX80

    Joined:
    Oct 8, 2019
    Posts:
    1
    Thank You Absolutely did the job for me!
     
    mcaldei01 likes this.
  19. nirflysher

    nirflysher

    Joined:
    Nov 5, 2017
    Posts:
    1
    This worked for me as well
     
    mcaldei01 likes this.
  20. whitesundreams

    whitesundreams

    Joined:
    Jan 23, 2020
    Posts:
    5
    I am suddenly having this age old issue today. I did not update VS2019 or Unity. Suddenly the Attach to Unity Option has disappeared. I am going to try to reinstall the unity tools.

    I tried to reinstall Unity's Editor and Unity Tools from the Visual Studio 2019 install tool, but that did not work.
     
    Last edited: Feb 13, 2020
  21. whitesundreams

    whitesundreams

    Joined:
    Jan 23, 2020
    Posts:
    5
    For whatever reason, it won't automatically show the attach to Unity. However I can still do it through the Debug options. Attach to Unity. Perhaps there was something that was hot patched?

    EDIT: And the next day it is suddenly back.
     
    Last edited: Feb 15, 2020
    mcaldei01 likes this.
  22. unity_1656rcYRBSHMmw

    unity_1656rcYRBSHMmw

    Joined:
    Jun 22, 2018
    Posts:
    1
    For Newbie’s Like me. After updating to Visual Studio 2019 I lost the Debug facility, I followed the procedure above/ Preferences/External Tools. At the top by External Script Editor the were some unusual Characters. I clicked on the dropdown list and there was Visual Studio 2019 (Community) after selecting that Debug works fine. Another issue for beginners. When I tried to download Visual Studio the page opened up Minimized and I could not find the Unity addon then the penny dropped and I clicked the maximize button and all was revealed.
     
  23. cgascons

    cgascons

    Joined:
    Feb 22, 2016
    Posts:
    25
    My 2 cents here, had the same issue today. Tried everything, some of the setting attributes stated in some of the posts above could not be found on my Unity Version (2020.1.0a25.3171 on Mac), so I finally figured out that the only thing that changed from yesterday (when I was debugging completely fine) and today is that I switched platform from Android to iOS. Reverting back the platform to Android made the Debug option appear back and everything's now working as intended.
     
    Last edited: Jun 11, 2020
  24. gprovs

    gprovs

    Joined:
    May 21, 2020
    Posts:
    1
  25. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    659
    From VS installer... Individual Components -> Visual Studio Tools for Unity

     
  26. John_MSFT

    John_MSFT

    Microsoft Employee

    Joined:
    Feb 21, 2018
    Posts:
    118
    Hey Folks,

    I'm the Program Manager of Tools for Unity at Microsoft. I'm reading through the pain here and it's super alarming. If you're still experiencing trouble like this, please use the Help > Report a Problem menu from Visual Studio to file an issue on Developer Community.

    One common reason VS would not show the Attach to Unity option is that the solution/project was not recognized as a Unity project and instead it was opened as a normal C# project. This usually means that the Tools for Unity extension is not installed.

    Another common issue recently was with Unity 2020.x versions and the new way external editors integrate - with Unity Packages. If you're using 2020.x with VS 2019 and have issues where IntelliSense isn't working or similar debugger options missing, update the "Visual Studio" package in Unity Editor > Windows > Package Manager to version 2.0.2.

    If you continue to have issues, follow the advice of Report a Problem above and feel free to send me a message so I can help troubleshoot to save you some time and pain - my apologies to those who already had to debug this on their own, but many thanks to the community here that stepped up.
     
    squeekee, kthrose and IN_Yves like this.
  27. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    This was it for me. After months of suffering with the debug menu way I made another attempt at finding the issue, and that was it. What does Unity do when you click that option that it usually doesn't!?
     
  28. AronTD

    AronTD

    Joined:
    Aug 31, 2013
    Posts:
    22
    Opening from Assets menu worked for me. Thanks!
     
  29. John_MSFT

    John_MSFT

    Microsoft Employee

    Joined:
    Feb 21, 2018
    Posts:
    118
    @Orion @AronTD

    What versions of Visual Studio and Unity were you using at the time of that issue?
     
  30. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
  31. lawura

    lawura

    Joined:
    May 22, 2019
    Posts:
    3
    Make sure to have your scripts in Assets/Scripts folder of unity project.
     
  32. ConanTheDeveloper

    ConanTheDeveloper

    Joined:
    May 8, 2011
    Posts:
    9
    This solution worked for me today
     
  33. Steve-OTheValks

    Steve-OTheValks

    Joined:
    Jul 29, 2018
    Posts:
    5
    Tried all the above with no joy. This one however worked for me. It did prompt that my Solution had changed and I had to confirm to Reload it. Then the Attach to Unity option suddenly showed up.
     
  34. webclaudio

    webclaudio

    Joined:
    Jul 29, 2018
    Posts:
    1
    ------------------------------------------------------------------------------------------------------------------------------------------------
    This really works !!! Even the intellisense that was not working, returned to work. Thanks a lot!!!
     
    mcaldei01 likes this.
  35. mattkeenum

    mattkeenum

    Joined:
    Aug 8, 2020
    Posts:
    1
    For me, it turns out that my project was not opening as a Unity project. Not sure what happened, but this solution worked for me.

    Edit -> Preferences -> External Tools -> Regenerate project files.

    When I clicked this button and switched back to VS, I was prompted to reload the project, and it loaded as a Unity project this time, allowing me to utilize the Attach to Unity button.

    upload_2020-9-29_20-21-1.png
     
  36. Aniko_V

    Aniko_V

    Joined:
    Jun 19, 2014
    Posts:
    2
  37. enricobeltramo

    enricobeltramo

    Joined:
    Feb 20, 2019
    Posts:
    8
    I have same issue I tested ANY of solution proposed and doesn't work.
    I tried:
    - reinstall all
    - enable / disable visual studio as editor
    - regenerate project
    - open from asset menu.
    When I open the C# files, it open correctly Visual Studio, and menu attach to Unity appears, but when I try to start debugger, it terminate immediately without any information.
    We are completely stuck in that problem, what should we do again?
     
  38. enricobeltramo

    enricobeltramo

    Joined:
    Feb 20, 2019
    Posts:
    8
    I fixed by myslef.
    We removed any previsious installations of Unity and Unity hub itself. After, we removed manually any file of previous installation left (there was some either after uninstall all). After reinstalled a clean version with Unity 2020.1.13F1.
    In my opinion in some cases, with multiple installations present, Visual Studio points to wrong Unity executable and is not able to attach correctly to process.
     
  39. devbr

    devbr

    Joined:
    Dec 26, 2011
    Posts:
    65
    Once in a while, this issue occurs and this solution has been working for me.
     
  40. Millenary_Fater

    Millenary_Fater

    Joined:
    Jul 23, 2016
    Posts:
    3
    Worked for me (Unity 2020.2.0f1)
    Thank you very much :)
     
  41. hungtom84

    hungtom84

    Joined:
    Mar 4, 2020
    Posts:
    1
    Be sure you has setup Unity debugger then go

    to Unity opened go to Edit\Preferences\External Tools and change to exactly Visual Studio ( I has done ... Last name before is Dev... ,It worked for me ! hope some cases can fix ^^
    upload_2021-1-19_1-8-56.png
     
  42. LHAppri

    LHAppri

    Joined:
    Aug 18, 2017
    Posts:
    20
    I just started working with Unity 2020.2.1f1, using Visual Studio 2017 v 15.8.9, with Package Manager packages of Visual Studio Code Editor 1.2.3 and Visual Studio Editor 2.0.5. I keep getting a situation (at least once a day) where the "Attach To Unity" button suddenly stops working instead it shows the "Select Unity Instance" dialog with no instances available even though I had been attaching and running successfully just 5 minutes earlier.

    Going to Debug | Attach Unity Debugger shows the same dialog but with 2 instances of Unity running, both Editor copies with different ports, even though I have no other instances of Unity open. I can attach to one of those versions (seems random which one) and it will correctly hit breakpoints while running. Attaching to the other seems to work but no breakpoints are hit.

    Closing VS & restarting it by double-clicking on a script from Unity does not help, nor does Regenerate Project Files.

    Exiting Unity & VS, ensuring all Unity processes are gone via Task Manager & then restarting from Unity Hub may or may not fix the issue. The only guaranteed way I have found so far is a full Reboot.

    This is getting time-consuming & frustrating. Any idea why it would suddenly spawn a second process or start using a second port?
     
  43. John_MSFT

    John_MSFT

    Microsoft Employee

    Joined:
    Feb 21, 2018
    Posts:
    118
    @LHAppri

    Sorry to hear about this issue! I will check with team on what might cause the behavior you mentioned - but in the meantime please report issues with Visual Studio using the Help > Submit Feedback > Report a Problem menu. That will help our team track and provide updates as we investigate.
     
  44. Polyfemos

    Polyfemos

    Joined:
    Nov 13, 2020
    Posts:
    25
    I've had the exact same issue that LHAppri describes above, but today the "Play" button is completely removed and replaced with a "Tools&Hammer" button, for building the project. But any trace of Unity is gone. Attach to process is greyed out etc.
    I've tried restarting, deactivating and reactivating the Unity plugin, but it's like any trace of Unity awareness are gone.
    Wierd thing is that this happened during a debugging session today. Poof, no more Unity integration.
     
  45. John_MSFT

    John_MSFT

    Microsoft Employee

    Joined:
    Feb 21, 2018
    Posts:
    118
    @Polyfemos

    Yikes! Please report the issue using the Help menu in Visual Studio. There is a Report a Problem menu in there that will guide you to Developer Community to file a bug. That will automatically include some logs and version information. Please document the issue and any other details you can share so we can investigate. Thank you!
     
  46. KGBemployee

    KGBemployee

    Joined:
    Nov 15, 2015
    Posts:
    3
    I also encountered this issue and resolved it using this technique.
    I am using Unity 2020.2.1f1.
     
  47. leonardpaiva

    leonardpaiva

    Joined:
    May 18, 2019
    Posts:
    2
    that worked for me, thanks.
     
  48. AvenSlayer

    AvenSlayer

    Joined:
    Jun 19, 2015
    Posts:
    6
    I clicked 'Open C# Project' on a random script and it fixed my studio: attach to unity appeared
    upload_2021-8-26_12-49-14.png
     
  49. Deleted User

    Deleted User

    Guest

    Updating everything to latest version in VS2019 fixed it for me and now I have an "attach unity debugger" option.
     
  50. shokerx25q

    shokerx25q

    Joined:
    Dec 30, 2020
    Posts:
    1
    This works for me