简体   繁体   中英

How do I fix Visual Studio Treating C# Unity Scripts as Miscellaneous, and thus not autocompleting?

This is an issue I've been having almost identical to this post from 2015 where some of the fix issues (such as downloading Tools for Unity 2015 when there is no modern counterpart I can find on the marketplace) seem outdated.

My situation is also unique in that I am attempting to edit scripts from an imported unity project, as I'm now on a new PC and needed to continue my Udemy coursework on a new install of Unity. I downloaded the project directly from the Udemy course's resources, which was admittedly on a much older version of Unity I didn't feel comfortable using, so I upgraded it to a newer version (2020.3.13f1).

I'm not sure whether this is an issue with the upgrade, importing projects, or what really. I should also mention that my version of Visual Studio was downloaded from within the Unity Hub along with the install of the Unity Engine itself, so I'm not really understanding why it wouldn't see even newly created scripts as tied to Unity.

Error message within Unity when attempting to open a script:

Win32Exception: ApplicationName='C:\Users\amoll\OneDrive\Desktop\Unity Projects\07-Glitch-Garden-6fe3e396cd56c6c514191c37dbc1b42107ecf6f8\07-Glitch-Garden-6fe3e396cd56c6c514191c37dbc1b42107ecf6f8\Library\PackageCache\com.unity.ide.visualstudio@2.0.11\Editor\COMIntegration\Release\COMIntegration.exe', CommandLine='"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe" "C:\Users\amoll\OneDrive\Desktop\Unity Projects\07-Glitch-Garden-6fe3e396cd56c6c514191c37dbc1b42107ecf6f8\07-Glitch-Garden-6fe3e396cd56c6c514191c37dbc1b42107ecf6f8\07-Glitch-Garden-6fe3e396cd56c6c514191c37dbc1b42107ecf6f8.sln" "" -1', CurrentDirectory='', Native error= The system cannot find the file specified.

System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) (at :0) System.Diagnostics.Process.Start () (at :0) (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start() Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor.OpenWindowsApp (System.String path, System.Int32 line) (at Library/PackageCache/com.unity.ide.visualstudio@2.0.11/Editor/VisualStudioEditor.cs:323) Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor.OpenProject (System.String path, System.Int32 line, System.Int32 column) (at Library/PackageCache/com.unity.ide.visualstudio@2.0.11/Editor/VisualStudioEditor.cs:224) UnityEditor.CodeEditorProjectSync.OpenProjectFileUnlessInBatchMode () (at <01e901910c5242498b7e69f6d2d8d500>:0) UnityEditor.CodeEditorProjectSync.SyncAndOpenSolution () (at <01e901910c5242498b7e69f6d2d8d500>:0)

First thing you should do is in unity to make sure that in Preferences and External Editors that Visual Studio 2019 is selected. If is already, then also try and right click anywhere in the project and click Open C# project. I had this problem and for some reason right clicking and selecting open C# project worked for me. Also try right clicking in visual studio and rebuilding the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM