问题
I'm using Visual Studio with Unity. In general in VS I can simply click "Attach to Unity" and it will build the solution and indeed attach to Unity. Sometimes, however, a project loses the "ability" to do so, what means that suddenly clicking the button will only build the solution and not attach to Unity.
I really would like to know what's happening there as I'm not aware of doing anything that could result in such a behaviour.
There are some parameters that might have an effect:
- it happens only for some Unity projects: a project is either "infected" or it happens never (on my watch)
- if it starts happening it will always happen until I reboot the PC (closing VS and Unity is not enough)
Thank you
回答1:
I had a similar issue, underneath the file tabs does it say miscellaneous files? To fix it I right clicked the Assembly C-Sharp in the solution explorer and rebuilt the project as shown in the picture.
回答2:
Normally just restarting visual studio is sufficient, this issue was addressed and fixed by MS in VS around early december. Previously it happened each time you made a new script file.
Make sure you have installed the latest visual studio patch, as well as the "visual studio tools for unity"
回答3:
I had this issue once, what fixed it for me was reconnecting Visual Studio to Unity Edit > Preferences > External Tools > External Script Editor
Also check the correct version of Visual Studio is listed there.
来源:https://stackoverflow.com/questions/55337121/visual-studio-loses-ability-to-attach-to-unity-why