Visual studio code auto-complete
Asked Answered
H

10

19

I have just downloaded unity and saw that now it supports Visual studio code, I downloaded it and made it the default editor.

After trying to edit a script, it prompted me to download c# extension and I did, but there is no auto-complete for unity functions. How can I get that? I'm on Mac. Any help is appreciated.

Hochstetler answered 5/12, 2016 at 21:8 Comment(1)
Does this answer your question? Unity Scripts edited in Visual studio don't provide autocompleteIrreconcilable
R
22

Maybe too late, but for future comers ...

There is an extension now for visual studio code called MonoBehaviour Snippets by Rachod Petchpho.

Press Ctrl+shift+x in the IDE to open extensions panel then search for MonoBehaviour Snippets, install and reload the IDE, now you will find all the autocomplete for the function names and objects just like MonoDevelop.

Ramiform answered 2/9, 2018 at 12:33 Comment(1)
Awesome project in place of a similar that automatically injected massive commenting everywhere. This is a great tool! thank you for sharing!Chabazite
S
8

I had the same situation and I bang my head to the wall for days. There was no solution on the net as there are few people using Unity on linux with Visual Studio Code. I finally removed mono and went to their site and downloaded the Visual Studio build (even though we use Visual Studio Code). Then volaaa. Auto complete and suggestions related to Unity functions were there. Of course after installing the necessary extensions.

https://www.mono-project.com/download/vs/

Singletary answered 20/7, 2018 at 15:18 Comment(3)
Worked for me on Ubuntu 16.04Ean
it helps in my Mac tooColleague
Worked on Fedora 31Infante
V
7

I had the same problem with Unity + VS Code combo.

I have found an extension called Unity CodeSnippets

I highly recommend to download it. This is much better than any of other snippets collection for VSCode.

Vertical answered 3/7, 2020 at 13:57 Comment(0)
K
5

Intellisense (Autocompletion) is a pure workflow of .Net Environment. So, you need to have .Net 'Developer pack' (not Runtime) installed on your system as it installs all three necessary components below:

  1. .Net framework
  2. .Net Target pack
  3. .net SDK

reference link: https://dotnet.microsoft.com/download/visual-studio-sdks

It is directly installed to a system admin-accessible path, so no need setting it up. Now, you have to tell VS Code which .Net version to use (whichever you have installed). Your Unity project will have these two files in the root directory:

  1. Assembly-CSharp.cs
  2. Assembly-CSharp-Editor.cs

In these both files search for line (probably 16):

<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>

Edit version that you had just installed (I had 4.8). Then reopen VS Code. Now everything should work fine.

Knur answered 14/8, 2020 at 16:1 Comment(2)
This worked for me, but I also had to go to Edit > Preferences > External Tools in Unity and set the external script editor to Visual Studio Code, then I clicked "regenerate project files" to get Assembly-CSharp.csproj to show up in my project folder.Rilda
Now, you have to tell VS Code which .Net version to use>> But HOW ?Dag
M
1

You can use the unity integration plugin:

https://code.visualstudio.com/Docs/runtimes/unity

Follow the instructions to get set up. It seems a lot of things to do but I think that's the best one.

If you still hit the issue even by using that plugin then follow this issue at their github page.

Mistranslate answered 5/12, 2016 at 21:20 Comment(1)
Thanks, but it doesn't seem like unity actually supports VSC or even has an official extension for it. For now I will just stick with Mono.Hochstetler
F
1

https://forum.unity.com/threads/cant-get-vscode-to-work-properly-with-unity.538224/

there are people that found a workaround. unityoracle user said: "This issue is that Unity Editor expects the file used to launch VSCode to have a specific name. " and: "Specifically, creating a symlink named "code" that opens VSCode fixed this issue"

Fidole answered 20/7, 2018 at 16:1 Comment(1)
What helped from there was Assets -> Open C# project. I also installed Mono (also a recommendation there)Cottontail
E
0

for me, it works by downloading .NET Framework 4.7.1 Developer Pack here here is the link

Evvie answered 29/9, 2021 at 21:15 Comment(0)
T
0

Follow the steps from https://code.visualstudio.com/docs/other/unity

Then in unity editor, set VS Code as the default Script editor:

Edit -> Preferences -> External Tools -> External Script Editor

Right below, set Embedded packages and Local packages to true

Turnstile answered 21/11, 2021 at 6:31 Comment(0)
T
0

i used these methods and it worked

  1. Change in External Tools: Edit -> Preferences :choose " Visual Studio Code"
  2. Open file : Assembly-CSharp-Editor in your project folder and Download the Framework Version that is the same as the version in this file EX: v4.7.1
  3. Open VScode tool - Settings - >code lens and tick.

source from here: https://www.gamesmobile.one/2022/01/visual-studio-code-auto-complete-with.html

Teeterboard answered 6/1, 2022 at 3:23 Comment(0)
N
-3

I installed an older version of c# vscode extension, version 1.16.21, and it is working.

Nembutal answered 22/11, 2020 at 13:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.