Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Scripts don't open with Visual Studio 2019 Through Unity

Discussion in 'Editor & General Support' started by Kidsm, Jul 2, 2021.

  1. Kidsm

    Kidsm

    Joined:
    Jan 26, 2019
    Posts:
    2
    Hello.

    I just started using unity 2021.1 and I encountered a problem with opening scripts via visual studio.

    After creating a new script I double clicked it in order to open it, weirdly enough visual studio didn't open.
    I made sure that my external script editor was set to Visual Studio 2019 and that I had the unity components installed via the Visual Studio Installer.

    After searching the web for a bit, I found a weird solution that for some reason worked even though it's very counter intuitive and involved removing the Visual Studio Editor and Visual Studio Code Editor packages via the package manager. ( https://forum.unity.com/threads/visual-studio-code-wont-open-through-unity-editor.758234/ )

    I'm not sure if it's the correct place to report this bug at, if it isn't please direct me to the correct place. I would also like to know if other people encountered this problem because it's pretty serious.

    Edit:

    Forgot to mention that I had Visual Studio 2019 prior to downloading Unity
     
    Last edited: Jul 2, 2021
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    jorgealonsomar likes this.
  3. Kidsm

    Kidsm

    Joined:
    Jan 26, 2019
    Posts:
    2
    First at all, thank you for replying!

    Secondly, I'm using Visual Studio 2019 Community Edition, not VS Code. The problem is not with intelisense ( well, as of now ) The problem is that scripts don't open at all while those 2 packages exist in the package manager, the second they are deleted the scripts magically open. I saw the first thread you posted yesterday and I already did everything in it.

    Also, after opening the scripts Unity doesn't create a project, only a solution. thus even if the script is finally open it isn't connected to the unity project at all. Similar to what this guy has: https://gamedev.stackexchange.com/questions/158596/no-project-in-visual-studio-using-unity-created

    The only difference is that in my case if I try to open the project via Assets -> Open C# Project I get the same warning but without any path printed by the warning message.

    So in conclusion I can't really work at all as of now because I either can't open the scripts or have them as part of a project.
     
    Last edited: Jul 3, 2021
  4. GameDeveloper1111

    GameDeveloper1111

    Joined:
    Jul 24, 2020
    Posts:
    100
    I'm also having this problem, with Unity 2020.3.14f1, and Visual Studio 2019 Community Edition 16.11.5 (latest version at the time of this writing). I have this problem even from a blank 2D template from Unity Hub:

    Config 0:

    upload_2021-10-28_16-0-13.png

    My .sln and .csproj files exist.

    Double click script from Project tab in Unity --> No response.
    Right click script --> Open --> No response.

    Config 1:

    upload_2021-10-28_16-2-39.png

    Same stimuli --> No response.

    Config 2:

    upload_2021-10-28_16-6-4.png

    upload_2021-10-28_16-6-58.png

    Notice the missing "Visual Studio Editor v2.0.11 enabled"

    Double click script from Project tab in Unity --> Visual Studio opens but the solution is not loaded and the script does not open:

    upload_2021-10-28_16-8-41.png

    This wasn't always this way, but I don't know what changed. I've had to get good at collecting file names and line numbers from the console, switching to Visual Studio, finding the file names in the tabs of opened files or in the Solution Explorer, pressing CTRL + G, typing in the line number, and pressing enter. I do this 100s of times per day now.
     
  5. Noctys

    Noctys

    Joined:
    Aug 23, 2013
    Posts:
    37
    Having the same issue with 2022 - did you ever find a solution to this?
     
  6. GameDeveloper1111

    GameDeveloper1111

    Joined:
    Jul 24, 2020
    Posts:
    100
    I did, but I don't remember exactly what worked. I recommend biting the bullet by reinstalling Visual Studio (which means you'll need set your VS preferences again and re-install VS extensions, unless you backup the former somehow). That's probably what I ended up doing.

    Recently, when the connection between Unity and VS is lost, I've been able to re-connect by deleting the .sln file and opening a script from Unity, but I'm sure you've tried that 10 times by now. The VS re-install is your best bet, despite the work it takes.