vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Scripts in "Editor" folder cannot access the classes in Unity project

Open ailuropoda0 opened this issue 6 years ago • 7 comments

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

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

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: 41faccf259

Runtime 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 avatar Oct 06 '20 06:10 ailuropoda0

@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 avatar Oct 13 '20 15:10 JoeRobich

@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.

ailuropoda0 avatar Oct 14 '20 05:10 ailuropoda0

I'm experiencing the exact same issue across multiple projects.

yullm avatar Oct 18 '20 15:10 yullm

I am also experiencing this issue in my own project since today.

ChacAndMeese avatar Dec 23 '20 02:12 ChacAndMeese

I downgraded the c# extension to version 1.23 to fix it.

yullm avatar Dec 23 '20 04:12 yullm

@yullm proceeding in a dichotomous way, I found out it is broken from v1.23.3

eytienne avatar Mar 18 '21 12:03 eytienne

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.

filipw avatar Mar 18 '21 12:03 filipw