Basics With Godot | Setting Up Godot C# With Visual Studio and VS Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is mitch with findpoint cgi and today we're going to go through the process of building your project in c-sharp with godot so we're going to go through the process of downloading and installing godot setting up godot to work with c sharp setting up visual studio code to work with c-sharp and if we have time we'll set up visual studio itself to work with godot so that's what i got in store for you guys today so let's go ahead and get started all right so the first thing you're going to do is you're going to come over to the good old website and click on the download icon let's go click on that we're going to download the mono version and you want to make sure you pull down this version this version has c-sharp support if you pick the standard version it's not going to work so what you're going to do is you're going to click on this 64-bit icon i've already downloaded it so i'm not going to download it again but you're going to download that and go ahead and extract that also while you're here come down here to the visual studio build tools or the mono sdk you can either download or install either one of them if you go to the visual studio tools it'll actually let you download visual studio from here and that would be a good time to go ahead and pull down visual studio and visual studio code so i suggest you pull down both of these you know click on it and then go ahead and download visual studio and click on visual studio code and download visual studio code you don't have to have both you have to have one of them but you don't have to have both i prefer visual studio over visual studio code for c-sharp development but that's probably just because i'm old and i've used visual studio for c-sharp development for years now so it's just i'm comfortable with it now if you choose not to download visual studio you'll need to come over here and download the mono debugging kit so you'll just go ahead and click on download mono 64-bit or 32-bit depending on which one is your operating system of choice so we'll go ahead and download the mono 64-bit and you'll see i'm gonna start pulling that down okay so the first thing that you can do is you're gonna have to install mono now i don't need to do this i've already done this so i'm not gonna run through all that but you just accept you install it and then you're good to go if you chose visual studio yeah i'll cancel that if you chose visual studio you just double click on visual studio community it's going to yell at you and then you go ahead and start installing it now i already have it all downloaded and installed so i'm not going to run through that but i'm going to make sure that um what will happen is it'll pop up here and it'll actually tell you the things that you want to install on your workload and i set mine up to pull down all of uh game development i did mobile development you don't have to do this one i chose to do it dot net for desktop development i suggest you pull that one down and if you're going to do any web development so for instance if your game is going to have like a web server or like a messaging system or scoreboard or something like that that needs to be housed outside of your project i suggest pulling down the asp.net and web development now once you guys have those downloaded and modified you just click modify and it'll start downloading and it'll start installing visual studio again you don't have to do that but this is one of the options now it's gonna kind of think for a bit all right now that that's installed and again you don't have to use the visual studio installer i just chose to because it makes life way easier for me now what we can do is we can go ahead and make sure we have visual studio code installed which i again i do um we need to make sure that we build out our godot project so let's go ahead and open up our godot stable and we will open this up now you can see i have a couple of things here but let's go here and type godot c sharp example and i'm going to create that folder and create edit now i'm going to resize this for you so you guys can actually see what i'm doing here because i always record on a much larger screen all right now there are some things that you just need to modify for you to be able to debug and do things like that in the c-sharp development so what we're first going to do is we're going to create a 2d scene i'm just doing that because we need a scene to debug so hit ctrl s we'll just call it node because again this is just a demo project so you know it's just something for you to learn now go to the editor menu editor settings here and then we're going to come down to mono all the way down at the bottom there's a mono section and i've probably already done this but if you click editor and you can change your editor to like visual studio visual studio code or something like that now in my case i prefer visual studio but i'll show you visual studio code first that way those of you who don't like visual studio can don't need to watch the rest of the video so click on visual studio code and then scroll up go to the text editor and let's change in the file section the open dormant script on scene change go ahead and get rid of that and what that does is if you have a script here when you click on it it doesn't automatically load the script here so that way you don't you're not just loading scripts randomly in godot it saves some trouble now after that we're going to go ahead and go to our project project settings and we're going to go down to mono debugger agent so debugger agent and we're going to want to make sure our port is 23685 which it is by default but just in case and you'll want to check wait for debugger now this is an important button if you have this button checked and you just click play your project will not run you need to click it from visual studio or visual studio code for it to work and if you have this unchecked then you cannot walk through code with visual studio or visual studio code so that's something to keep in mind that this is really important so go ahead and hit close and now that we have our scene created and we have everything set up let's go ahead and attach a script real quick so let's click right click attach script change this to c sharp and just call this hello world actually no we'll call this player might as well because if we're going to be making a player controller you know so player controller so what that's going to do is it's going to generate our solution and you'll see that it opened it up in visual studio code which is a perfect through line to us doing visual studio code and setting all that up so now mine's already set up but i'll walk through the process again for you so if you click on this little four little boxes here and then you search the extension marketplace you go c sharp and you download the c sharp add-on by microsoft and then you type c sharp godot and there should be a c-sharp tools for kado so you'll want to make sure you install that as well and what that will do is it will 100 percent debug allow you to debug and do all the configurations you can see it actually does it all for you which is fantastic so once you have both of these installed c-sharp and c-sharp tools for godot that will primarily do it for you in terms of setting up your visual studio code so if you click on your little file icon and click on player controller if we do gd for godot dot uh print [Music] hello world and i will capitalize my h so i don't get yelled at and i saved that how would we go about debugging this well if you click on this little run and debug and you say hey i need to create a launch json file so you click on that and what that'll do is it'll pop up this little pop-up here you see it already has this nice little thing set up here for c-sharp godot so if you click on that bam it's already created it so now all you have to do is you just click play in editor and you'll notice that godot will fire off in a second once it does all of its compiling and things like that and now it's going to go ahead and build our solution it's going to run and you'll notice it says hello world now if it doesn't automatically pop up with this make sure that you set your default scene and if you do set your default scene you will need to re-run your project so you'll need to just go here and click play an editor and it'll just handle it from there so now if we click stop this there we are if we go back to our explorer and we do our c sharp player controller we click play or we click on the little break point here and we click back here and play an editor you'll notice that it will break right here there we go so that's how simple it is really to set up c-sharp inside of godot it's that simple now if we hit play you'll see it's playing simple enough i mean they've come a long way with adjusting and setting up our cs proj and all of that it does all of that for us which is fantastic so if you only wanted to see how to set it up inside of visual studio that's all you need to do it's that simple so now that we've gotten it to debug and do all of that now what we're gonna do is we're gonna go ahead and set this up for visual studio to work with it now it's slightly different and there's a lot more complexity that gets added into this and uh it's something that we're definitely gonna have to be careful about if that makes sense so what we're gonna do is first we're gonna close visual studio so now that we close visual studio we're gonna come up here to editor editor settings and we're going to go to mono editor and change this from visual studio code to visual studio and that's going to allow us to use visual studio instead of visual studio code so go ahead and hit close right click on here click on show in file manager what that's going to do is it's going to open up a file manager with your guys's project all right then what we're going to do is we're going to double click on our little solution here all right and that's going to go ahead and fire up visual studio so at first glance what you're going to notice is you're going to notice all of your stuffs here so that's exciting even even all of the c sharp stuff that you would normally expect so like gd dot you can see it does come up with all of the stuff that you would expect so you know like print or if you were to type in like you know um like vector three you know vector three is equal to a new vector three right like all that stuff that you would expect is actually here which is great but if you hit play you'll notice that visual studio yells at you and says hey um you can't do that right the reason why is because you need a very specific extension to allow you to debug this so let me go ahead and show you which extension it is all right it's called the godot c-sharp for visual studio extension now the instructions on setting this up is a little on the sparse side so i'm going to take you through it it's pretty simple but it could be a little on the complicated side so if you come up here and you click on releases and you pick the godot add-in vs vsix file here it's going to let you save that and then you'll be able to go ahead and open it now you need to close your visual studio and you can see i've already installed it but go ahead and close your visual studio and run this little add-on and go ahead and run this little add-on and you'll see that for me it's already installed but just go ahead and install it once you have it installed go ahead and reopen up your visual studio now the easiest way to know if it's actually installed is by coming up to here to your extensions and click manage extensions and you'll see if you go to installed godot support support for the godot engine c-sharp projects which is perfect that's exactly what we want so now if we close this and we try hitting play well that still didn't work right the reason why is the extension and the support for visual studio has kind of fluctuated a little bit since this plug-in was created so you're gonna need to do a little bit of cheesing to get this to work i'll throw a link in the description below that'll kind of go through a workaround that helps you make this work now i'm gonna go ahead and show you how to do the work around but you're gonna need to copy and paste the project file and i will um supply a link to where you can actually copy and paste that project file so we'll go ahead and hit ok so the first thing that we need to do is we need to right click up here click add new project and then what we're going to do is we're going to type class because we need to create a class library now we don't want this specific class library because this is for netstandard or net core that's specific for like future versions of godot uh we don't want this f sharp one because that's f sharp it's not c sharp this is visual basic we don't want that one and if we keep scrolling all the way down here we'll have a classlibrary.net framework a project for creating a c class library.dll we'll go ahead and double click on that we'll name it stub and i'm just going to throw it into my documents folder because it doesn't matter where it's located so let's go ahead and hit create all right now that we have this what we're going to do is we're going to right click and set it as our startup project which is right there so let me re-show you where that's at right here set as startup project so click on that and you'll notice that we have a little start button here if we click on that you'll see hey uh this doesn't work what are you doing right so what we need to do is if we open up our stub cs providing that it allows us to which it might not yeah we're probably gonna have to open it up so if we right click on it and we open in file explorer and we right click on this and we open well it's not gonna let us open it with visual studio code so i'll just bring up visual studio code and what we'll do is we'll drag this individual studio code or you can open it up with notepad or something like that if you'd like but i'm going to use visual studio code all right now you'll see that it's got all these different references and things like that well first what we need to do is we need to copy and paste some project information which i'll throw in a comment below or in the description of the video for you guys but we just copy and paste that information into here we go ahead and hit save and then we open up visual studio you'll see that's gonna say hey this was modified so yep go ahead and reload it that's fine and you'll notice that something changed play an editor so if you go ahead and hit that what it's going to do is it's going to go ahead and call out to godot and execute it perfect right we're there we open up our player controller we hit breakpoint here and we do play an editor well you'll see that it says application is in break mode right well did we break out our thing we don't know right so if we hit continue execution well godot started but it didn't break at our break point and the reason why is because the assembly is getting loaded in it's the assembly is getting loaded outside of the build environment so think of it kind of like this we're building the c-sharp example or an i called a c example because if it's c-sharp example it'll actually break your project but it's building this and it's building this separately but we need these two to build together right so we need to create a reference from this to this right so we can do is we can click the down arrow all right i guess we don't have to click the down arrow but we can click add reference and go ahead and add our c sharp project and go ahead and hit ok and then if we go to our player controller and we hit play in editor now that we have that assembly loaded okay well some things got a little touch and go there for a minute but i got uh it working so it looks like the problem was if you see how i have godot c-sharp example in my previous section these did not match my actual project name so if you actually come up here and you go to project settings you look at your application name those all need to match if they don't match your project will not compile i found that out by bringing this over here for you by reading this little uh blurb here where they were talking about changing the project name actually breaks all the c sharp scripts and i found that if you change your project settings name and then you run the project it'll actually completely bork everything so that's something to keep note if you do run into this issue what you can do or at least what i ended up doing was i ended up see you can see here's the originals where i changed these names um because of reasons but um what i did was i remade my references to the actual cs praj and i deleted my mono vs and import so i got rid of these three and then i reloaded my project and hit play and then that just rebuilt everything and rebuilt all my all of my stuff so that's just something to keep in mind uh when you are running into something like that that's a good way of of handling it if that makes sense all right so where in the world did we leave off it was about four hours ago so uh oh yes if we put a break point right here and we go ahead and hit play in editor after we've hooked this reference up to here if we hit play in editor you'll see that it will now break point right there so now i can go ahead and step through my code as if it's visual studio code so that's what i have for you guys today we went over how to set up c-sharp inside of godot we went over how to set up visual studio code to work with godot and how to set up visual studio to work with godot i showed you guys how to walk through your code with both um applications and i showed you guys how to do some basic debugging with mono because model support is still very much beta alpha-e so i know it's getting officially supported at least i'm told in 4.0 but that's what i have for you guys today and if you like this video hit that like button if you dislike that this video go ahead and hit that dislike button because i'm here to make content for you guys and this video was a viewer request and that's how i do 90 of my video ideas so if you guys have ideas throw them in the comments below and i'll be more than happy to take a look at them and add them to my schedule but anyway thank you guys so much for watching i'm gonna see y'all next time [Music] thanks
Info
Channel: FinePointCGI
Views: 4,522
Rating: undefined out of 5
Keywords: godot, godot engine, godot tutorial, godot game engine, godot 3, godot getting started, getting started with godot, godot for beginners, godot 3.1, godot beginner tutorial, getting started with godot engine, godot engine tutorial, godot engine getting started, godot tutorials, godot tutorial for beginners, godot c#, godot 3.2, godot game, native code in godot, godot 3 tutorial, Basics With Godot | Setting Up Godot C# With Visual Studio and VS Code, Visual Studio, VS Code
Id: lOjOb4Lv_ww
Channel Id: undefined
Length: 21min 16sec (1276 seconds)
Published: Mon May 10 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.