Search Unity

Can't see "Attach to Unity" button in Visual Studio

Discussion in 'Editor & General Support' started by CesarOrozco, Mar 30, 2017.

  1. CesarOrozco

    CesarOrozco

    Joined:
    Dec 30, 2016
    Posts:
    14
    Hi,

    I have downloaded the latest Unity and Visual Studio versions, and I'm trying to debug a script but I can't see the "Attach to Unity" button in Visual Studio, I have seen some videos and the button should be here:



    I tried to search but I couldn't find anything related to the missing button, any ideas?

    Thanks!
     
    DoomDude99 likes this.
  2. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    What version of visual studio do you use? The one that comes packaged with unity seems to work fine out of the box for me...
     
  3. CesarOrozco

    CesarOrozco

    Joined:
    Dec 30, 2016
    Posts:
    14
  4. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Did you try the one packaged with the unity install? Or downloaded separately?
     
  5. CesarOrozco

    CesarOrozco

    Joined:
    Dec 30, 2016
    Posts:
    14
    I tried both of them, first with the one packaged with Unity and then the other one
     
    whatnotory likes this.
  6. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Hmm. So you say you also used the "vs tools for unity" (I think thats what the installer says) when installing right? If that all went correctly I'm not sure why thats happening, because I see the button:

     
  7. Zenix

    Zenix

    Joined:
    Nov 9, 2009
    Posts:
    213
    The 'button' is a menu item under 'Debug'. There's no button on the main interface. The 'Attach...' button that MD_Reptile is showing is for attaching to standard applications (not Unity ones).
     
    russpatterson42, damobe and Danarchy like this.
  8. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Opps my bad.
     
  9. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254

    I question the correctness of the highlighted (red) portion of the above statement. The below is a screenshot shows that the Start button is replaced with Attach to Unity.

    [Image lost to time, Sorry]

    Currently I have it attached correctly, yet my co-worker next to me can't get it to attach. We've both selected VS 2017 in the unity preferences as that came installed by default (5.6) Both have VS2017 tools for unity installed and enabled.


    EDIT: This fixed it for my co workers (YMMV):
    1. Close VS
    2. In Unity Select File > Build Settings
      1. Select the Development Build Checkbox
    3. Save Project
    4. In Edit > Preferences > External Tools
      1. Re-select your VS IDE (VS 2017)
    5. Double Click a script and let Unity initialize VS
     
    Last edited: Jun 17, 2022
  10. Zenix

    Zenix

    Joined:
    Nov 9, 2009
    Posts:
    213
    The highlighted text is correct. The standard "Attach..." button that is shown when you have no solution open is for attaching to non-Unity applications. It is equivalent to selecting "Debug->Attach to Process...", when what you want for Unity apps is "Debug->Attach Unity Debugger".

    If you have a button on the main interface that says "Attach to Unity", then that's a different button to what I (and MD_Reptile) was talking about. If you have this button (I don't, "Attach..." becomes "Start" for me when I have a solution open) it's probably safe to use it.
     
    MD_Reptile likes this.
  11. lilQ

    lilQ

    Joined:
    Feb 21, 2018
    Posts:
    1
    This worked for me as well. Thanks!
     
  12. bhallion

    bhallion

    Joined:
    Mar 26, 2018
    Posts:
    5
    Thanks !

    This was crucial for me.
    Also I didn't installed the unity extension at all so you might need to install the extension using "Visual Studio Installer".
    vsi.png
    (Source: https://forum.unity.com/threads/support-for-visual-studio-2017-rc1.444124/ )
     
    jayamohanan96, isgoed, EVART and 2 others like this.
  13. BrockKunz

    BrockKunz

    Joined:
    Oct 25, 2018
    Posts:
    1
    I am having this same issue. I have tried all of the suggestions posted here, and it still has not fixed my issue. My debugger button just says "Start". I do seem to have Unity specific intelliSense. However, if I right click as I have seen some do there is supposed to be an option to implement some Unity specific methods, and I am not seeing that option either.

    I have uninstalled Unity and Visual Studio and reinstalled them several times without any real result. Also when installing Visual Studio Community 2017, I only select the to install Game Development with Unity option, everything else is default.

    I have set Visual Studio 2017 Community as my default external editor in Unity preferences. I also have "Create Visual Studio Solution" and "Development Build" selected in the build settings.

    I have no idea what else to do... I am able to attach the debugger through the debug menu. However, doing this over and over becomes cumbersome and inconvenient when you have to do it so many times.

    Current Unity Build Version: 2018.3.0f2

    Microsoft Visual Studio Community 2017
    Version 15.9.5
    VisualStudio.15.Release/15.9.5+28307.280
    Microsoft .NET Framework
    Version 4.7.03190
    Installed Version: Community
    C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
    C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
    NuGet Package Manager 4.6.0
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
    ProjectServicesPackage Extension 1.0
    ProjectServicesPackage Visual Studio Extension Detailed Info
    Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
    Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
    Visual Studio Code Debug Adapter Host Package 1.0
    Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
    Visual Studio Tools for Unity 3.9.0.3
    Visual Studio Tools for Unity

    Any help will be much appreciated!
     
  14. sonicsquirrel9999

    sonicsquirrel9999

    Joined:
    May 6, 2019
    Posts:
    13
    Same problem here. Odd thing is, when at first I am starting up VS, as it is loading I can see the Attach to Unity button. However when it finishes loading, the button is replaced by the Start button. Not sure what's going on...
     
  15. furkan59

    furkan59

    Joined:
    Apr 18, 2017
    Posts:
    7
    may be some updates make this error. Same thing happens to me today. I am using vs 2019 for unity. Tools for unity is installed. But I can not see attach to unity button.
     
  16. furkan59

    furkan59

    Joined:
    Apr 18, 2017
    Posts:
    7
    I have vs 2019 and vs 2017 both could this be a reason for this ?
     
  17. furkan59

    furkan59

    Joined:
    Apr 18, 2017
    Posts:
    7
    I have deleted vs 2017 and problem still exists

    I have tried deleting vs tools for unity for 2019 and reinstall it. Still not solved.
     
  18. furkan59

    furkan59

    Joined:
    Apr 18, 2017
    Posts:
    7
  19. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Thanks for posting what solved it for you! :)
     
  20. x421

    x421

    Joined:
    Oct 14, 2019
    Posts:
    1
    removing the (hidden) .vs folder from my unity-project-folder finally resolved this problem for me :)
     
    kasuyakema, nyizhar and MD_Reptile like this.
  21. EVART

    EVART

    Joined:
    Jun 15, 2015
    Posts:
    1
    frite333 and bhallion like this.
  22. Bakhtiyargill

    Bakhtiyargill

    Joined:
    Feb 13, 2020
    Posts:
    1
    My VS2019 Tools for Unity was disabled by performance manager. These tools caused visual studio to be unresponsive. That's why performance manager disabled it . I enabled it and this worked for me
     
  23. bhallion

    bhallion

    Joined:
    Mar 26, 2018
    Posts:
    5
    Annotation 2020-02-18 114719.png
     
  24. Chrisc2600

    Chrisc2600

    Joined:
    Jan 29, 2016
    Posts:
    1
    My VS2019 was missing the attach to Unity as well. 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'. May take a few minutes to install.


    you can all so open the Visual Studio Installer separately and select modify from the installer which will bring up the above dialog.

    Once installed you should see the Attach to Unity under the Debug menu.
     
  25. andreapomposelli

    andreapomposelli

    Joined:
    Apr 24, 2014
    Posts:
    5
    In case you still have an issue, this should automatically fix potentially issue on the project :
    Preference > External Tool > Regenerate project file

    upload_2020-5-23_23-49-51.png
     
  26. favoritjj

    favoritjj

    Joined:
    Jul 1, 2020
    Posts:
    1
     
  27. amcakebread

    amcakebread

    Joined:
    Nov 8, 2016
    Posts:
    28
    worked for me - thanks
     
    CaptainNoah and kevomara like this.
  28. pablolluchr

    pablolluchr

    Joined:
    May 23, 2017
    Posts:
    2

    This solved it for me!
     
    CaptainNoah and kevomara like this.
  29. GuitarBro

    GuitarBro

    Joined:
    Oct 9, 2014
    Posts:
    180
    Yep, same here. Weird that this was literally fine yesterday.
     
    CaptainNoah and kevomara like this.
  30. unity_Cz2KQCPxNfDI3g

    unity_Cz2KQCPxNfDI3g

    Joined:
    Sep 27, 2019
    Posts:
    1
    You're a hero.. Thanks xD
     
    IndieMarc, CaptainNoah and kevomara like this.
  31. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    676
    For others who might come this way: Intellisense was helping with Unity classes (listing methods when I typed a class name or variable of a class type), but not with private methods. So "void OnM" wasn't prompting me with a list including things like "OnMouseDown." As it happened, I did not have Visual Studio Tools for Unity installed, so I added that with the Visual Studio Installer.

    That's when everything went wrong.

    First up, upon next opening of Visual Studio, it complained that I was lacking some kind of reference to System.Void, and about a hundred other errors I'd never seen before. I tried "Regenerate project files" and that made things worse. My errors remained, but upon next opening of Visual Studio, it added eleven more projects to my solution, one for every package in the "Packages" folder in my Unity project, and three more (not sure where from). I fussed with this for a couple of hours, including using Visual Studio Installer's "repair" option. No help.

    A complete uninstall and then reinstall of Visual Studio, with the Visual Studio Tools for Unity included, fixed all problems.

    Using Visual Studio Community 2017 and Unity 2019.4.7.
     
  32. Simpowitch

    Simpowitch

    Joined:
    Nov 13, 2018
    Posts:
    14
    This happens every month for me, seemlingly randomly the "attach to unity" disappears in projects and versions of unity that worked the day before. Has happened for me for 2 years now in different versions of both unity and visual studio. A more permanent solution is needed. I can change "external script editor" in preferences to something else and then back to visual studio and it will fix itself, but only until next month or so.
     
  33. kasuyakema

    kasuyakema

    Joined:
    Sep 13, 2020
    Posts:
    11
    That solved it, thanks
     
  34. urbiman

    urbiman

    Joined:
    Dec 3, 2019
    Posts:
    3
    It seems there are also issues in case you are using directory links. Moving the scripts out of the linked directory did solve the issue in my case.
     
  35. V1adosK

    V1adosK

    Joined:
    Dec 15, 2019
    Posts:
    1
    The only solution for me was: Assets -> Open C# Project
    And only after this action the button "Start" was changed to "Attach to Unity" and also the correct markup
     
    DevJaydee and DiegoWw like this.
  36. Maark7

    Maark7

    Joined:
    Dec 2, 2020
    Posts:
    1
    Thanks it worked for me
     
  37. Khoray

    Khoray

    Joined:
    Mar 1, 2017
    Posts:
    1
    After I deleted the following files/folder and then re-open the project the my problem was solved.

    .vs folder (this folder is hidden)
    .csproj files
    .sln file
     
  38. rishitsood

    rishitsood

    Joined:
    May 14, 2020
    Posts:
    1
    Thanks a lot this works for me
     
  39. metroidsnes

    metroidsnes

    Joined:
    Jan 5, 2014
    Posts:
    67
    I'm not sure if it wasn't mentioned before but one reason for this problem to happen ("Attach to Unity" button replaced with "Start") is a mismatch between VS and Unity versions. I was using Unity 2018.2.14 with VS 2019. Changing to VS 2017 fixed the issue.
     
  40. pjbaron

    pjbaron

    Joined:
    Jan 12, 2017
    Posts:
    53
    This attach button changes to Start as VS2019 loads happens to me quite frequently with Unity 2020.1.17f1 and VS2019 fully patched and with Unity Tools installed (of course).

    Many of the above solutions did not work for me. What finally did work is deleting just the .sln file and letting Unity/VS Studio rebuild it.

    Other things I tried previously that did not work:
    - set Unity build settings to 'development' and reselect the external editor
    - delete the hidden .vs folder
    - delete the .vsconfig file

    I believe that changing VS version is just doing the same thing but will take a lot longer so I hope this suggestion helps others get going again quickly when hit by this incredibly annoying problem.

    I didn't try 'regenerate project file' before I found my own solution (or, in this case, deleted it ;) ) but I wonder if that is also a better way of forcing a refresh of the .sln file.
     
  41. eddyb

    eddyb

    Joined:
    Mar 6, 2013
    Posts:
    5
    This worked for me, thanks! (Quick & easy solution too.)
     
  42. ayresjeremiah

    ayresjeremiah

    Joined:
    May 2, 2021
    Posts:
    1
    YOU ARE THE MAN!!!
     
  43. RendergonPolygons

    RendergonPolygons

    Joined:
    Oct 9, 2019
    Posts:
    98
    @ndreapomposelli 's solution worked for me, thanks a bunch !
     
  44. rrtenz

    rrtenz

    Joined:
    Aug 23, 2019
    Posts:
    2
    This worked for me (I'm on a MacBook):

    Go to Run -> Attach to Process
    Screen Shot 2022-03-02 at 11.38.33 AM.png

    Then I saw my Debugger had been switched to ".Net Core Debugger" so I switched it to "Unity Debugger".
    Screen Shot 2022-03-02 at 11.38.43 AM.png

    Screen Shot 2022-03-02 at 11.38.50 AM.png

    Then I had the option to connect to "Unity Editor" (I think you have to have the app running in Unity first). Screen Shot 2022-03-02 at 11.38.56 AM.png
     

    Attached Files:

  45. DevJaydee

    DevJaydee

    Joined:
    Apr 24, 2017
    Posts:
    3
    Bump, This solution works for VS2022
     
  46. flexprods01

    flexprods01

    Joined:
    Aug 19, 2022
    Posts:
    1
    This worked for me. my issue was that i did not have VS selected in External tools
     
  47. anilreddy1353

    anilreddy1353

    Joined:
    Dec 28, 2021
    Posts:
    1
    Thanks, it's Helpful.