Search Unity

Visual Studio 2022 and Unity

Discussion in 'Editor & General Support' started by amiga4K, Nov 14, 2021.

  1. amiga4K

    amiga4K

    Joined:
    Jan 30, 2018
    Posts:
    71
    Hello,
    I just installed Visual Studio 2022 with Unity 2021.1 and the package Visual Studio Editor 2.0.12 but it seems as nothing is working anymore.

    The same problem with Unity 2021.2.

    No link with Unity...

    Has anyone else had the same problem as me?

    Thanks.
     
    ceitel and arca_98 like this.
  2. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    is this version supported in unity? I see only packages for visual code or visual studio 2019
     
  3. amiga4K

    amiga4K

    Joined:
    Jan 30, 2018
    Posts:
    71
    https://docs.unity3d.com/Packages/com.unity.ide.visualstudio@2.0/changelog/CHANGELOG.html

    Code Editor Package for Visual Studio
    [2.0.12] - 2021-10-20
    Integration:

    • Do not block asset opening when only a VS instance without a loaded solution is found.
    • Only check package version once per Unity session.
    • Improved support for Visual Studio For Mac 2022.

    Maybe not? Only for Visual Studio For Mac 2022???
     
  4. GuidewireGames

    GuidewireGames

    Joined:
    Apr 20, 2017
    Posts:
    27
    I think you need to "Regenerate project files". That at least worked for me
    upload_2021-11-16_16-1-6.png
     
  5. amiga4K

    amiga4K

    Joined:
    Jan 30, 2018
    Posts:
    71
    Unfortunately it didn't work for me. However your IDE is Visual Studio 2019. Mine is Visual Studio 2022. In fact the post concerns VS 2022.
     
    DarthGaydar likes this.
  6. jp-unit

    jp-unit

    Joined:
    Aug 15, 2020
    Posts:
    10
    Any solution to this, I also have the same issue.

    In Unity->Preferences->External Tools->External Script Editor I have broswed to:
    C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe

    I regenerated the project files.

    Unity is not opening scripts etc
    If I manually open and edit the C# scripts then VS 2022 doesn't recognise the unity libraries etc

    I'm not sure what to try next.
     
  7. jp-unit

    jp-unit

    Joined:
    Aug 15, 2020
    Posts:
    10
  8. jp-unit

    jp-unit

    Joined:
    Aug 15, 2020
    Posts:
    10
    This solved it for me:

    Be sure the Player Projects is Ticked.
    Then press Regenerate project files.

    upload_2021-11-18_15-18-5.png
     
  9. jp-unit

    jp-unit

    Joined:
    Aug 15, 2020
    Posts:
    10
    Scripts open perfectly from Unity, and all Unity libraries are functioning in the VS2022 IDE correctly.
     
    Flamehawk, Stellarrush and DrMeatball like this.
  10. cjzachary

    cjzachary

    Joined:
    Nov 23, 2021
    Posts:
    1
    I am having the same issue but on windows, any one have a solution for windows?
     
    Clousck likes this.
  11. XxSadPandaxX

    XxSadPandaxX

    Joined:
    Nov 6, 2017
    Posts:
    2
    Thank you, Uninstalling VS2019 and Targeting VS2022 and adding Player Projects Did the Trick for me. VS2022 Works with unity now.
     
    Yugix_Saga and TheOtherBCD like this.
  12. Razvan_Savin

    Razvan_Savin

    Joined:
    Dec 7, 2021
    Posts:
    2
    I regenerate all .csproj files, now i can work well in Visual Studio 2022. Thank you!
     
    evbe and DevDunk like this.
  13. minispuks

    minispuks

    Joined:
    Dec 23, 2021
    Posts:
    1
  14. paulioms

    paulioms

    Joined:
    Jul 29, 2021
    Posts:
    15
    Neither fixed it for me. Or at least I keep getting the 'This Unity Project was not generated...' message in VS2022. Seem to work alright though <shrug>
     
    ecreators, rockyouxw and mareksabov like this.
  15. ecreators

    ecreators

    Joined:
    Oct 23, 2016
    Posts:
    7
    Also have no checkbox for project files to tick.
     
  16. huseyinseber

    huseyinseber

    Joined:
    Jul 26, 2016
    Posts:
    1
    worked for me.
    when you click the Player project tick.
     
    ceitel likes this.
  17. DiesInLives

    DiesInLives

    Joined:
    Jul 23, 2021
    Posts:
    2
    If you are refreshing after ticking on "Player project" only, it won't work...You have to close Visual Studio 2022 (if open) and then open it again by clicking on the script you want to edit...If you have not opened VS2022 then you can ignore this.
     
  18. JamesJukie

    JamesJukie

    Joined:
    Jan 6, 2020
    Posts:
    1
    I just changes the editor in the preference, regenerated the project files and it worked fine.
     
  19. Cyzet

    Cyzet

    Joined:
    Mar 30, 2021
    Posts:
    1
    I just change from 2019 to 2022, I already tick all boxes in the external tool still doesn't work. But inside visual code on "Solution Explorer" panel or tab. There are files like "Assembly-Csharp" and more still (unloaded).

    I try to select all those unloaded files and right click "reload project" and it works hope it help
     
    SomeGuy22 likes this.
  20. jazzy-rey

    jazzy-rey

    Joined:
    May 27, 2017
    Posts:
    2
    for anyone that is still going through this the only thing you have to do is update Visual Studio Editor Package on Package Manager to the 2.0.15 version or higher.
     
  21. VeNHyper

    VeNHyper

    Joined:
    Jan 10, 2022
    Posts:
    1
    worked for me.
    when you click the Player project tick.
     
    ceitel likes this.
  22. U20220418

    U20220418

    Joined:
    May 3, 2022
    Posts:
    1
    What should I do if I don't find the visual studio editor package in my package manager
     
  23. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    305
  24. grippie

    grippie

    Joined:
    Mar 16, 2018
    Posts:
    10
    Thsi worked for me!!! Thanks so much.
     
    EnigmaFactory likes this.
  25. izzy-game-dev

    izzy-game-dev

    Joined:
    Nov 15, 2020
    Posts:
    2
    Awesome, this worked for me!
     
    EnigmaFactory likes this.
  26. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    514
    Might help someone. I just installed the Visual Studio 2022 and i had issues getting the Unity Explorer Code View to appear. Also the solutions explorer was not showing any code saying it was closed.
    I added the Unity work bench tools from the Visual Studio 2022 Modify menu and regenerated projects but still no good.
    In the end i noticed a little exclamation mark with an install link in the solution explorer panel saying that i was likely missing some important install. I installed it and everything appeared. So watch out for that!!!

    Feel free to remove Visual Studio 2019 and no need to install it on installing from the unity hub.
     
  27. Halo_Shrimp

    Halo_Shrimp

    Joined:
    Aug 27, 2021
    Posts:
    11
    When I using vs2022, coded a script and go back to the unity editor, it told me Missing UnityEngine.Bridge
     
  28. helgrind21

    helgrind21

    Joined:
    Sep 13, 2018
    Posts:
    24
    In my case, I can open the project files on VS2022 through unity but VS2022 does not display the play button to enable debugging. I'm using a mac. Would anyone know how to solve it?
     
  29. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    same issue, solved by disabling/fixing broken script:
    I guess importing Visual Studio Editor package didn't get to compile, until fixed errors in scripts.. (had created the script before imported package)
     
  30. b00ne

    b00ne

    Joined:
    Oct 19, 2022
    Posts:
    1
    Finally it works. God bless you.
     
    EnigmaFactory likes this.
  31. ProfAbdelati

    ProfAbdelati

    Joined:
    Nov 22, 2022
    Posts:
    1
    This solved it for me:
    Be sure the Player Projects is Ticked.
    Then press Regenerate project files.
    Thank you
     
    BruceKristelijn likes this.
  32. Preddiee

    Preddiee

    Joined:
    Aug 18, 2020
    Posts:
    2
    Thanks! This did it for me, finally after hours of searching!
     
  33. RemVas

    RemVas

    Joined:
    Dec 24, 2017
    Posts:
    1
    My case was very unusual, but it took me almost an entire day to solve it and I thought it might be worth to mention it here, in case somebody may have a similar situation. I also work with web projects on a Windows machine with IIS, and that requires Visual Studio to be run as an elevated process. So, to make is “easy” for me, I configured Visual Studio to always "Run as administrator" by adding the path to devenv.exe to the registry at Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers. But it seems that Unity cannot communicate with Visual Studio if it is run as an elevated process. After I deleted the permanent setting in the registry, Unity started to work well with VS again. Now I use shortcuts and other "less comfortable” methods to start VS as admin for particular projects.
     
    fcl93 likes this.
  34. AsperGames

    AsperGames

    Joined:
    Jan 8, 2023
    Posts:
    1
    This has also solved my issue, thank you.
     
    EnigmaFactory likes this.
  35. DarkFact

    DarkFact

    Joined:
    Dec 27, 2013
    Posts:
    9
    I have noticed that if VS2022 is open, say you have a script open when you do this it may not work properly. I did what you did but had to with Unity being the only thing open, regen the files, then opened VS2022 by double clicking the file and it worked for me. So, make sure files are being held captive by outside application from unity before regenerating files.
     
  36. Isoettes

    Isoettes

    Joined:
    Feb 24, 2023
    Posts:
    1
    Thank you so much, this worked.
     
  37. steelyjim

    steelyjim

    Joined:
    Nov 21, 2021
    Posts:
    2
    Dude! I owe you a beer! I have a project that installs a service so I had VS running as admin. I used the compatibility checker to create that registry entry and removing it solve the problem. Thanks!
     
  38. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    I'd also like to chime in to say that it seems like VS 2022 was not attempting to "reconsider" the cs projects even after regenerating project files, deleting the .sln, and other fixes from this thread. Note that if you use "Player Projects" in the Unity settings, yes you will get some working projects but they'll be loaded on top of the original broken projects. Player projects seem to be an option for working with different player (platform, i.e. mobile vs console) configurations and likely not the type of projects you usually want to work with when coding in the Editor. Hopefully this hasn't tripped anyone up as the true "fix" would be to repair the original "Assembly" projects.

    What finally fixed it for me was right clicking "reloading" every project in the solution. It seems the first time I opened the solution it didn't find it compatible and I just needed to refresh in order for it to work. Which is strange because even deleting and regenerating the .sln didn't cause this to happen; perhaps some state on the local device is trying to save performance by not doing the check again. Hope that helps!
     
  39. enzzilla

    enzzilla

    Joined:
    Mar 20, 2024
    Posts:
    2
    i have that problem
     
  40. enzzilla

    enzzilla

    Joined:
    Mar 20, 2024
    Posts:
    2
    i cant find the regenerate button upload_2024-4-13_1-4-25.png