D
D
Danya Kozlovskiy2020-09-05 00:51:34
C++ / C#
Danya Kozlovskiy, 2020-09-05 00:51:34

Why can't Visual studio code see unity?

Hello, there is a problem. Initially, in VSC, in the omnisharp logs, which, as I understand it, is responsible for the fact that VSC does not issue Unity hints (such as tranform, rigidbody, etc.), there was an error that it needed exactly 4.7.1 net fraemwork . The problem was solved by removing net fraemwork updates i.e. rollback to about version 3 and installing 4.7.1 first, and then 4.8.1 as well. VSC swore at his absence. No more errors, but VSC still doesn't want to see the unity files (or whatever it needs to see). Extensions for VSC are all installed, namely: C#, unity tools, unity snippets, unity debbuger. In unity, VSC is also selected for opening scripts.

Logs from omnisharp to VSC:

Starting OmniSharp server at 05.09.2020, 00:49:10
    Target: d:\games\unityProjects\ddddddd\ddddddd.sln

OmniSharp server started.
    Path: c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\OmniSharp.exe
    PID: 3720

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2019 16.5.30002.166 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
            2: StandAlone 16.8.0 - "c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin"
[warn]: OmniSharp.CompositionHostBuilder
        It looks like you have Visual Studio 2019 installed without .NET Core SDK support which is required by OmniSharp.
 Try updating Visual Studio 2019 installation with .NET Core SDK to enable better MSBuild support.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild
            MSBuildToolsPath = c:\Users\tolstyak\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'd:\games\unityProjects\ddddddd'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'd:\games\unityProjects\ddddddd\ddddddd.sln'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\games\unityProjects\ddddddd'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'd:\games\unityProjects\ddddddd' on host 5008.
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: d:\games\unityProjects\ddddddd\Assets\scri.cs added to workspace

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danya Kozlovskiy, 2020-09-05
@morto

I solved the problem, maybe it will be useful to someone in the future. It will also work for installing VSC for Unity. Solution taken from here . Below I have painted the points.
Some of the steps may not be helpful, but it's still best to stick with the below, unless you know better than me, of course.
1.
Remove the C# for Visual Studio Code (powered by OmniSharp) extension and all unity extensions for VSC from VSC.
Delete projects with this VSCode crutch (from the unity folder).
Remove all .net fraemwork, .net CORE, .net SDK. We delete both in programs and components (control panel -> programs and components), and in viewing installed updates (control panel -> programs and components -> viewing installed updates ( button on the left) ) by clicking on each update by driving in its name (for example, KB4054566 ) in the search engine to see what it is, namely, we need any .net fraemwork.
REBOOT THE SYSTEM.
2 .
We install everything that was removed in this order (if you don’t want to follow the links below and download it yourself, then you need to download DevPack, otherwise it won’t work):
1. .net fraework 4.7.1
2. .net fraemwork 4.7.2
3. . net core
REBOOT THE SYSTEM.
3.
Install extensions in VSC, namely: C#, Unity tools. Close VSC.
4.
Create a new project in Unity. Go to Edit -> Preferences -> External Tools, specify the path to VSC if you haven't already, and enable all the checkboxes in " Generate .csproj files for: ".
It should look like this:
5f538c1274ced962994049.jpeg
5.
Open our script from the unit and press ctrl + shift + u in VSC, the console will appear and select c# omisharp log from the drop-down menu on the right, and csproj files should be indexed there. After indexing, it will start displaying objects and class methods for all kinds of objects, components, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question