Scripts in "Editor" folder cannot access the classes in Unity project
Issue Description
Steps to Reproduce
Expected Behavior
No error. Unity Editor compiles my project without any problem.
Actual Behavior
Omnisharp cannot access classes in my Unity project from the "Editor" folder. "The type or namespace name '[class_name_in_the_project]" could not be found" kind of errors occur in the script files in ~/Editor/ folder which calls the classes in the Unity project. There is no error on other script files not in ~/Editor/ folder.
Logs
OmniSharp log
C# log
Environment information
VSCode version: 1.49.3 C# Extension: 1.23.2
Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 3.1.302 Commit: 41faccf259Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.302\
Host (useful for support): Version: 3.1.8 Commit: 9c1330dedd
.NET Core SDKs installed: 3.1.302 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
| Extension | Author | Version |
|---|---|---|
| csharp | ms-dotnettools | 1.23.2 |
| gc-excelviewer | GrapeCity | 3.0.40 |
| python | ms-python | 2020.9.112786 |
| unity-debug | Unity | 2.7.5 |
| unity-tools | Tobiah | 1.2.12 |
@ailuropoda0 Sorry things aren't working. Are you opening your Unity project's root folder in VS Code? OmniSharp will load the generated Unity .csproj files based on finding the .sln file in that root folder.
@JoeRobich I have opened VS code by clicking the script in Unity Editor, which would work as opening my Unity project's root folder in VS code. So there are .sln file and the generated .csproj files in the root path in VS code.
But anyway, now it has been fixed even though I am not sure what was changed. Thanks.
I'm experiencing the exact same issue across multiple projects.
I am also experiencing this issue in my own project since today.
I downgraded the c# extension to version 1.23 to fix it.
@yullm proceeding in a dichotomous way, I found out it is broken from v1.23.3
This is a duplicate of #4113 and it is not an OmniSharp bug, but rather OmniSharp's change to fix incorrect project handling unveiled a bug in Unity's VSCode package.
You need to make sure that your Unity VSCode package is updated to at least 1.2.3 https://github.com/OmniSharp/omnisharp-vscode/issues/4113#issuecomment-718006809 and that "omnisharp.useGlobalMono":"always" is set. After this upgrade, the Unity projects need to be regenerated too.