How to Setup Visual Studio Code for Unity with Autocomplete (in Windows 10)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello internetters, In this video I'm going to show you how to get visual studio code, and make it properly work with unity. With full autocomplete by installing right extensions and .NET SDKs. So let's get into it. So, let's open up the browser, type in visual studio code It should be the first result. You can also go straight to code.visualstudio.com/download Here, you gonna check the windows 10, 64 bit installer. Click on it. Wait for it to download. (Download took 20 Seconds) Now, let's click on it. click I accept the agreement. Click next. Now the default install folder is C but I'm gonna change this. I'm gonna click browse. Gonna close the C drive. Click D. Programs. And this is where I want it so click ok. D://Programs/Microsoft Vs Code. Click next. Next. Here you can choose what you want, so create a desktop icon. I'm gonna check everything. You don't have to. This basically adds: Open with code when you right click on a file that supported by it. Now click next. Click install. (Installation took 8 Seconds) Check launch visual studio code and click finish. Let's make it big. Now we can go to extensions over here. Type in C# which is needed for unity. Click install. And there are many more things we need to do in order to make it compatible with unity. But first let's close this. And let's type in, in google: Vs code for unity. Click the first result. Here you have a bunch of guidelines of how to make sure Vs code works very well with unity. So we can follow this. I'm gonna do it throughout the video. But first let's connect our Vs code to unity. So let's open up unity hub. Go to projects. We gonna need to create a new project. Let's call it random project. You can choose which location you want the project to exist in. So I'm gonna change this. I'm gonna actually keep my project in My E drive which is a Hard drive but isn't a SSD because I have a lot of space here. Gonna go to projects. New. Folder. I'm gonna name it Unity. Select folder. And now all my unity projects are gonna be in E://Projects/Unity You can of course have it in your main Unity folder where you installed the hub and the unity editors. Just do what you feel is right. This doesn't really matter because we're just connecting now Vs code. So let's click create. Starting a project might take awhile so just be patient a little bit. (Project took 46 Seconds to Open) Ok, so now that the project is open, let's make it big first. Let's go to Edit, Preferences, Here you have external tools. External script editor. Open by file extension. Here we gonna click browse. Now here we need to find where our Vs code is installed. So, we installed it in D, Programs, Microsoft Vs Code. Click code. And there we go, now it's connected. Everything is fine here. Click X. Let's right click on here. Create. C# Script. Let's name it: RandomScript. Open the script. And as you can see, it opens up in VS Code. Click i trust the authors. Now, if we're gonna start typing something, like: gameobject. As you can see, we don't have autocomplete Because we need to finish setting up Unity for Vs code based on the guidelines in this article. So let's see what else we need to do. We need to install the .NET core SDK. So let's click on this. Let's go to the new tab. Let's install .NET 5.0 SDK. Click here: download .NET SDK x64. Wait for it to finish downloading. (Download took 40 Seconds) Ok. Once it's finished downloading, let's click on it. Click Install. Click Yes. (Installation took 20 seconds) Click close. Now we can close this. We need to restart windows but we gonna do it a bit later. Install the C# extensions. Choose Vs Code in external script editor. We have already done this. Let's install all these extensions. So, Debugger for Unity. Let's go to Vs Code, Extensions. Type in: Debugger for Unity. Here, we can click install. (Installation took 13 Seconds) The other extensions we're gonna need is Unity tools by Tobiah. So let's type in: Unity tools. Click install. And then we can install Unity code snippets or Unity snippets, by one of those authors: by Kleber or by YCL. So, let's type in: Unity snippets. Click Install. And Unity Code Snippets. Click Install. By the way, if you find one of those extensions to be bothersome and you don't want them, you can always uninstall them. You just go to extensions, without search and you can see you have all the extensions you have installed. So, if you need to let's say remove: Unity code snippets or Unity snippets, you can either disable it or uninstall it By clicking one of those. But for now let's just keep them. So, let's get back to the article. Now we also need to make sure we have the right .NET framework targeting pack. This says 4.6 but maybe we need a different version. The way you know which version you need is by going to Vs Code. So, here you can see you have an error message. Get the .NET core SDK. Let's click on this. So, we gonna need to restart the computer for the .NET SDK to kick in. But first let's see if there's anything else we need to do Before we restart. Ok, Let's go back to Unity. Here there is one more thing we need to do. Let's go to window. Package Manager. Here we can see we have visual studio code editor, and make sure we have the latest version. See other versions. Ok, So we have the latest version. If you have a different version, let's say you have 1.2.1. You gonna want to go to the latest version: 1.2.3 and click "update to" which is gonna look like this. In case you didn't have it installed. And make sure you have the latest version, and that about it. So, now I'm gonna close everything and restart the PC and be right back. Ok, so now after we finished restarting the PC. Let's open Unity hub again. Open our project. (Project took 36 Seconds to open) Now, Let's open our script. Let's type in: gameobject. As you can see, we have some autocomplete but it's not full. And that because we don't have the proper SDK targeting pack. Let's click here on the warning. Show output. And here we can check which targeting pack we need. So let's go through this. Here we can see: fail on The reference assemblies for .NET framework version 4.7.1. This is the version we need. So, Let's open up the browser. Copy this version. 4.7.1. So let's type in: download .NET 4.7.1 targeting pack Click the first result. Here click download. (Download took 9 seconds) Click on it, after it's finished downloading. I Agree. Install. Yes. Close. You can close this. Now let's reopen our script. Close the script. Now reopen it. And we can see we no longer get the warning message. So let's go to start. Start typing in: gameObject. And as we can see, now we have all the autocomplete that we need. So we can autocomplete gameObject. Then, click . (Dot). And you can see all the properties and all the functions we can use with it. So, with that we are done setting up VS Code for Unity.
Info
Channel: Tech Mammal
Views: 6,329
Rating: undefined out of 5
Keywords: How to setup visual studio code for unity on windows 10, How to setup visual studio code for unity, Visual Studio code autocomplete not working in unity, How to setup visual studio code for unity with autocomplete on windows 10, How to fix the error missing .NET SDK targeting pack in vs code, How to install vs code extension for unity, Visual studio code for unity, VS code for unity on windows 10, How to fix vs code autocomplete not working, Tech Mammal, How to link VS code to unity
Id: mGi-GFiUKEY
Channel Id: undefined
Length: 8min 56sec (536 seconds)
Published: Thu Jun 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.