I am trying to solve a problem I never had before. I just made all my students install Unity 2020.3.19f1 (LTS) from Unity Hub and Visual Studio Community 2019 (version 16.11.2) has been added automatically. All computers have W10.
Of the 18 computers I have performed the installation, I have 2 of them that are giving me the next issue:
I create a new C# Script, open it in VS, write a print(“whatever”); line, save it (asterisc disappears, so it’s saved), assign it to an object and press play. Then, nothing happens. Console doesn’t show anything. When i select the script, the inspector shows nothing written on it, but when I double click, the line is there.
I’ve tried multiple solutions I’ve found online, but nothing has worked so far. The only thing that solves it is restarting Unity, which is not great. All packages are up to date.
First check that Edit → Preferences → General → Auto Refresh is checked
Then check that Edit → Preferences → External Tools → Visual Studio is set as your code editor
Apart from what GroZZleR said you should check if the Unity tools are installed in Visual Studio. Inside Visual Studio click on “Tools and Features” inside the “Extra” menu. This should open the Visual Studio installer and show the installed extensions and packages. Make sure you installed the Unity tools. My locale is set to german so I can’t tell you exactly how it’s called. Though it should be something like “Game development with Unity”.
I always recommend that you start visual studio from inside Unity. This usually ensures the correct communication between Unity and VS. So first start Unity. Make sure Visual Studio is closed. Double click on a script inside Unity and it should open up VS. Now you should be able to switch between the two without any issues.
Another note: Don’t run Unity or VS as administrator. This will cause countless privileges issues since windows will restrict communication between applications running at different privileges levels. So make sure there are no dodgy compatibility settings on Unity or VS.