Home > database >  Visual studio Autocomplete for Unity does not work
Visual studio Autocomplete for Unity does not work

Time:06-16

Visual Studio Code with Unity I have installed VS code and Unity on a MacBook Air with M1. My unity version is: Unity 2021.3.4.f1 Silicon LTS. I have set external tools in unity to work with visual studio.

Things I have installed: homebrew and wget, .net core, Mono stable channel, Mono visual studio channel, SDK dependencies, In visual studio: C# extension, Unity code snippets - Kleber Silva, Unity snippets - Ycleptic Studios

I tried to set OmniSharp Global mono to always but I couldn’t find it in VS code settings so I added "omnisharp.useGlobalMono": "always" to my settings.json. And I have restarted my computer a dozen times.

I have tried to check all Generate .csproj files in unity

My Visual studio does not autocomplete code for unity and when I compile a console.write(“hello world") it runs only on my terminal but it doesn’t launch in the VS code.

CodePudding user response:

You can try as follows:

  1. edit->preference->external tools.

enter image description here 2. Change the default to visual studio.

enter image description here 3. After setting, the c# script will be opened as a unity project when it is opened through vs.You can also refer to this link here. it is helpful

CodePudding user response:

I managed and here is the solution. First I will post the errors I had so people having the same issues can find them more easily. If some step is not here you can also dm me bcs I had a big amount of errors.

Also link Unity to VS code if you haven't done so. It is in the comment above.

1: Install homebrew if after installation it does not work in terminal, run export PATH=/opt/homebrew/bin/:${PATH} now it should work. However, whenever I close the terminal I need to do this command again.

2: Install mono sdk either through mono-project.com (both channels for MacOS) or through homebrew

3: Export mono to path: PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:${PATH}

4: Install dotnet sdk https://dotnet.microsoft.com/en-us/download - arm64 if you have M1 chip. Otherwise x64 for intel versions. Export dotnet to PATH if dotnet --help shows you errors (even though 'dotnet' command itself may work)

5: In visual studio code install these extensions: C#, Unity code snippets - Kleber Silva, Unity snippets - Ycleptic Studios. Click on settings of C# extension (not VS code settings but settings of the actual c# extension), type 'useModernNet' and uncheck the box 'omnisharp.useModernNet'

I may have missed some steps but I will update them in less than a month because I will be reinstalling everything in my personal Mac.

**Also follow the steps here: https://code.visualstudio.com/docs/other/unity **You can see all the export PATH locations in this folder /etc/paths.d - here should be mono-commands, dotnet and maybe more stuff **If you need settings.json from VS code, it is located here: Library/Application\ Support/Code/User/settings.json

  • Related