I work with unity and the VS code autocomplete does not complete many unity objects and more..
I have 2 extensions on my VS:
1.C# for Visual Studio Code (powered by OmniSharp).
2.Unity Code Snippets.
I'm using windows 10 and I looking for answers on the web for weeks, I tried to play with the settings, open new projects, reinstall VS CODE and nothing happen.
also I saw that it's happen mostly to people with an old version of Unity but it's not my case..
I work with unity version 2021.1.15f1 personal and VSCODE 1.59.1
This is a picture that illustrates the situation
Apologies if you've tried everything there already, but following the instructions at this link have helped me get auto-complete for Unity set up in VS Code when I got started: https://code.visualstudio.com/docs/other/unity
One key aspect that I had missed originally was the Unity Script Editor set up section. IntelliSense only starts working after you have opened a script via the Unity Editor rather than straight in VS Code. It generates an Assembly-CSharp.csproj file at the root which is necessary for enabling the functionality.
Make sure that Visual Studio Code is selected as the default "External Script Editor" in your Unity preferences.
To do that in Unity, go to Edit->Preferences and then select "Visual Studio Code" as your preferred external script editor. Restart VSC afterwards.
Related
I recently installed unity ,but I didn't install visual studio with it because I already have installed.
I simply opened unity and I goes to Edit > Preferences > External script editor and I selected Visual studio code . But when I opening my scripts, visual studio not giving hints for my c# code.
You probably need to install the appropriate targeting pack for Unity. That article also has some other helpful extensions to install when developing in Unity.
What you could do is just open it and close it.
What i mean by that is go to Assets > Open C# Project
Once VSCode opened, wait for 1 min, try to write something like Rigidbody.
If intellisense is working it will start giving you hints, if it's still not working
Do the process one more time,
You can refer to these pictures where how VSCode tells you whether Intellisense is working or not.
http://imgur.com/gallery/1YiuPA4
You need to install snippets for Unity in VS code.
Open VS code. Go to Extensions(ctrl+shift+X).
In search field you need to write unity
Then click to Unity Code Snippets and install it in window bellow.
Then you will be able to see Intelesence !
I recently came back to unity, as i found out that it does now support installation linux. It works, but when editing the scripts with vscode i do not get code completion.
I have installed the C# extension, the Debugger for unity extension and the Unity Code Snippets extension.
I know that there is the Visual Studio IntelliCode extension, but this does only support Java, Python js and ts. I also know that there are IDEs that i can use, like Rider, but i would like to setup this in a lightweight environment without an IDE.
So, how do i setup code completion in vscode for unity-scripts on linux?
Have you tried this guide
Install Unity Editor
Install Visual Studio Code
3.Tell Unity to use VSCode
n project preferences -> external tools you can tell Unity what program to use for editing c# scripts. If you have the Visual Studio Editor packages in your project, you should see a special “Visual Studio Code” option in your preferences. The packages are part of the standard Unity download now.
Install dotnet
Install mono-complete
Most people forget step 3
I tried everything in the installation guide, but code completion would still not work.
Somewhere I read that setting Use Global Mono to always in the C# extension for VS Code might fix the problem. So I did that, restarted Unity, Unity Hub and VS Code, and then it started working correctly.
I just heard that Unity will be dropping support on MonoDevelop on its 2018.1 version and went to search for an alternative. VSCode was the best option so I downloaded it and installed all suggested Unity extensions. (https://code.visualstudio.com/docs/other/unity)
I also changed my External Script Editor to Code. I've created a new Unity project for testing. The code snippets are working great for unity methods such as Start () and Update () but whenever I try to declare a variable like:
private Rigidbody rb;
The rigid body is not suggested. I decided to test with other data types, the most essentials like int, float, etc. And none of them are suggested either. What could be happening? Why is IntelliSense not working properly? I've already downloaded the C# extension as suggested at https://code.visualstudio.com/docs/editor/intellisense
I'm on a Mac using MacOS Sierra with the most current version of VSCode and Unity 2017.1.
[EDIT] The problem was solved after I reinstalled, MonoDevelop, VisualStudio for Mac, VSCode and all it's extensions and used mad.meesh suggestion of searching the .sln on project opening. I still don't understand why, but it's working.
Old question, but I had the same problem just recently.
There must have been an issue in your Assembly-CSharp.csproj or project-name.sln files. Most likely to be the .csproj file. If you take a look at it, you will see various references to .dll files.
You can tell Unity (my version: v2019.2.20f1) to create these for you by enabling Edit > Preferences > Generate all .csproj files.
Delete both files.
Enable .csproj file generation.
Double click on a script in Unity.
This fixed my issue.
I followed the tutorial from Microsoft for VS Code with Unity and it seemed to finally do the trick... https://code.visualstudio.com/docs/other/unity
Steps I took:
Installed https://dotnet.microsoft.com/download
Installed https://www.mono-project.com/download/stable/
Installed C# extension in VS Code.
Unity > Preferences (cmd + , on Mac) > External Tools (left toolbar) > External Script Editor > Visual Studio Code.
Then this is the trick I found to work after doing all of this... I open up VS Code prior to starting my Unity Project and manually go into the Unity Project folder and open up everything in VS Code FIRST. Then, with that project already open and working in VS Code with Intellisense, I double click the script in Unity and it will open it up in the already opened VS Code editor and have Intellisense already working! Do my normal workflow for the day and close everything down... then when I start up the next time, just be sure to open the project in VS Code FIRST and then VS Code will recognize it's a C# project and initiate Intellisense and all that jazz.
Hope this helps!
I've been using Visual Studio Code with unity for around 2 months now without problems, but since last week I suddenly get no more Intellisense (no code completion for C# or Unity). I don't recall changing anything and I have no idea why it suddenly stopped working.
I was using Unity 5.4 with this recommended plugin to enable VSCode integration when Intellisense stopped working.
I've already reinstalled VSCode and updated Unity to version 5.5. Unity 5.5 has built in support for VSCode, so I've removed the editor plugin from my project. I can indeed open Unity scripts in VSCode without the plugin now, but I'm still not getting any code completion.
I saw there was an update for the C# VSCode extension today, but updating that didn't help either. I've attached a screenshot of the log during this update:
As you can see there's no flame icon and the code completion is missing. The Omnisharp log is either empty or completely missing (not sure why this behaviour is not always the same).
Does anyone have any idea what I can do to fix this? Thanks.
So in my experience, whenever something weird like this happens in Visual Studio, the first thing you should do is kill all instances of VS and restart. For good measure, you could even reboot your computer, though this is often not necessary. If that still doesn't help, the next best thing is to reset your VS settings which can be done by going to
Tools -> Import and Export Settings -> Reset All Settings
A backup of the current settings are recommended, but not required.
After checking that VS is the default editor in Preferences, open your Unity project with Explorer. See if you can find a .sln file, and open it with VS. Then, go to your solution manger inside VS and try and open any of your Unity project's scripts from the manager. After doing this, your Intellisense should be working.
This worked for me when I had a similar issue side time ago.
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.
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.
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/
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.
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:
.Net framework
.Net Target pack
.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:
Assembly-CSharp.cs
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.
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.
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"
for me, it works by downloading .NET Framework 4.7.1 Developer Pack
here
here is the link
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
i used these methods and it worked
Change in External Tools: Edit -> Preferences :choose " Visual Studio Code"
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
Open VScode tool - Settings - >code lens and tick.
source from here:
https://www.gamesmobile.one/2022/01/visual-studio-code-auto-complete-with.html
I installed an older version of c# vscode extension, version 1.16.21, and it is working.