 Visual Studio Toolbox, it's all fun and games. We always have fun. Today we're going to see with Visual Studio and Unity that you can build games like this. Hi, welcome to Visual Studio Toolbox. I'm your host Robert Green and joining me today is Arturo Nunez. Hey Arturo. Hey Robert, how are you? Good. Arturo works with Unity and so we're going to talk today a little bit about gaming. Yes. And Unity and Visual Studio have gotten along very well together for quite some time and it only gets better. Yeah. So you're going to show us some of the new things in the latest version of Unity, latest version of Visual Studio. You're going to turn me into a game writer in less than 20 minutes. It's just going to be awesome. That's all. Yeah. Cool. Yeah. So let me talk to you about Unity first. Okay. So of the audience who doesn't know what Unity is. Unity is it started as a game engine, but now we call it a creation engine. Basically you can create games, but you can also create interactive applications for VR, AR, in 3D, 2D. So that's what we are doing now. If you do HoloLens, there's Unity. If you do Mixed Reality, there's Unity. Right. So we support 30 plus platforms. So basically if you want to deploy your project to any platform that's out there, you can with Unity. Okay. Cool. Yeah. So the tool is pretty easy to use. So if you're an artist, you can grab Unity, you can create something cool without having to program. If you're a programmer, you have complete control over what you want to do. Like if you want to program the graphics, you can do that. If you want to program the behavior of your characters or the things that's there, you can absolutely that. Using C-Sharp, that's the language we support. So you create the graphics, the UI, if you will, in Unity, which is its own IDE, and then in Visual Studio, you do the scripting that you can do in C-Sharp and other languages to actually control what happens. Right. So Unity takes care of everything, like the rendering, the audio, all of those things for you. So you just need to focus on the behavior-specific for your project. That's how it works. It's C-Sharp. We support other languages, but the best experience is it's using C-Sharp. Right. Yeah. That's what Unity is. Yeah. So let me show you a demo using Unity. So this example is called Angry Bots. Something like six years ago, we had the same demo. Now, with the newest features of Unity, we're showing the same project, but with the newest graphics addition. So this is how Unity works. It's an editor. It's software. So you can basically drag and drop stuff into your project. So in this case, I created this spider robot in another program. This is a 3D model. The textures were made in another program. I bring those into Unity, and I simply can position them whenever I want. So you need to have this type of graphics capability. I need to be able to draw floors and robots. That's a good question. And usually, you can if you have the ability to make them. However, we have something called the Asset Store. Okay. So basically, if you just want to focus on the coding part, you can go there, grab some stuff that is pre-made, some animations that are pre-made, and just use them for your project. Right. And then you can edit those if you want to. Yeah, absolutely. If you like this spider, but you want another color, or you want to make some changes. More legs, fewer legs. Right. That's possible. So that's how you create your world. You can have a 2D or 3D project, and the only thing you have to do is simply click Play to start the simulation of your project, and you can start playing right away. So Unity also takes care of all the inputs. So if you're playing on a PC, or an Xbox One, or whatever, Unity will translate that input into whatever you are working on. So it's a really simple game, a shooter, that space marine. We have a lot of tools inside Unity to create these things. However, the powerful thing here is that you, as a programmer, can add behavior on top of everything that Unity offers you, either on the runtime or on the editor. Unity is fully extensible, so if there's something that Unity doesn't have right now, you could go there and extend the Unity editor. So yeah, that's in and of itself what Unity? So the creatures that bought the space marine, that comes with some built-in behaviors, like the ability to go forwards and backwards and left and right and jump, et cetera. And then you program additional stuff. Right. So some of these objects already come with built-in behavior. So if you want to start prototyping or doing some of those things, we offer you a collection of assets that you can simply drag and drop and start having something like a camera that moves around or a character that walks around. But as you progress during your development, maybe you want to code the specifics for that project you want. So that's where the program. I think that if you're just starting out, you'd want to reuse stuff that's already made and get the feel for how it works and then get better and better in terms of creating your own images, your own assets, et cetera. So yeah, that's the idea, that you get started using Unity real quick, but if you're an advanced user, you can do whatever you want. So yeah, that's it. So this is the editor of Unity and the best idea for editing your C-sharp code. And I'm saying this truly, it's Visual Studio. I've been using Visual Studio for forever. Every time we are working closer with Microsoft, so the experience gets better and better, right? So now we have the ability to debug your Unity projects in Visual Studio and the workflow is so clean and so fast. That's one of the things that I'm super excited about. So yeah, this is a basic C-sharp script for Unity. Basically, if you want to respond to Unity's built-in messages, you need to extend the MonoBehavior class. But if you already know C-sharp, I will say you're like on the other side, you already know most of the things you need to do to start. So it brings up an interesting question. Unity is on the mono runtime, right? So what version of C-sharp, what version or equivalent version of .NET, if I come in here, how much of what I'm used to, would I be able to actually run inside here? Right, so we're revamping that. A couple of years ago, we were still using all versions of C-sharp and Mono. Right now, we offer support for the equivalent of 4.2, or 4.x runtime. C-sharp, currently we support C-sharp 6, but with the newest version of Unity, we're going to support C-sharp 7 features. So we're trying to get there to provide the latest tools that are out there. Then that gives you the ability not only to do basic C-sharp, but call into various framework stuff, talk to Azure if you want to store information up in the Cloud or whatever, because it's .NET. Yeah, absolutely. So yeah, that's something that you can absolutely do. Also on the performance side, now with these upgrades of the runtimes we're getting performance boosts, also some bugs have been fixed now. So yeah, it's pretty exciting. Yeah. So yeah, I just want to show you a couple of things of how the workflow works if you're using Visual Studio and Unity. So for instance, as you have seen here, the Unity comes with a project window. So this window has all the assets in your project. So from textures, sounds, scripts, videos, everything. If you're a programmer, you might not necessarily care about these assets. You just want the code, you just want to have the scripts somewhere in your ad hand. So with Visual Studio, if you go to here window, there's a new Unity project explorer, and this tool allows you just to see the scripts in your project. So if I'm just focusing on programming right now, I don't need to worry about clicking other assets that I don't care about. Another cool thing, and this is if you know already C-Sharp, but you don't necessarily know the specifics of the Unity API, you can go to the documentation, do things like that, but if you just want to get up to speed with this, there's an awesome feature. Then I see the screwdriver there, see a full support for Roslin. Yeah. Or at least much support. Yeah. So there's an option if you click control shift M, the implement Unity messages option appears. So all of the messages you see here, sorry, are messages that any one of the behavior can receive from the engine. So every time you click play, you need calls start on all the objects that are on the scene. So yeah, sometimes we have a lot of them. So maybe you don't know all of them. This feature, it's super useful. So in case I want to say, please Visual Studio define, sorry. I don't know. The untrigger, enter message, right? If I want to listen to whenever two objects collide with each other, then Unity is going to notify me, okay, something collided here. I didn't have to go to a browser to search how the correct signature for this method. So it's pretty quick. I also want to show you how easy it is to debug. This is very important because in the previous IDE Unity used or what I was shipping with, it was kind of hard to do debugging. So developers ended up just printing everything to the console, and it's difficult to do that. That's not the best tool to do that. Within Visual Studio, you can simply add your breakpoints as you do if you already know to use Visual Studio. In this case, this breakpoint will be called every time I shoot a projectile and within Unity, I can simply attach to Unity and play. So I don't need to be switching between Unity and Visual Studio. So I can simply say, okay, Visual Studio launch Unity while you connect to that process. So I can now start debugging my project here. So as soon as I shoot, Visual Studio captures that event and I can inspect as you already do in Visual Studio. So it's pretty cool tools for developers. Also important because Unity is now used by other industries, people making interactive applications. So most people are new to programming. So having these tools at hand, super easy to use is very important for us. So new to programming, what if you've been doing.NET for a while, C-Sharp, web apps, line of business apps, and now you want to try your hand at gaming. So the part where you write C-Sharp code in Visual Studio is pretty familiar. You can go to the Asset Store and get a bunch of assets, but how hard is it for somebody that's just used to writing regular line of business apps to come over and learn the world of gaming and graphics. And graphics. Yeah. So there are a lot of resources on the web on how to learn using Unity either by the community. But we also have official documentation. I think it's fun to work on these because if you're trying to follow a tutorial, you're making a game, right? So you get excited about shooting stuff, about collecting points and things like that. So there's a lot of documentation on that. One thing I always recommend people on doing is at least knowing the basics of graphics or math. It's not required, but I think you can have more fun if you do. Yeah. Well, you have to understand the underlying platform. Like if you say, well, I know C-Sharp, I'm going to go use Xamarin and write mobile apps because Xamarin is just C-Sharp. And you get over there and the code you write is similar. But if you don't really understand the iOS runtime or the Android runtime, how great an app can you write? And if you come over into Unity and C-Sharp and you know a few things we don't really understand what the engine is doing, how great a game can you write. So you do ultimately need to get pretty good at that kind of stuff. Yeah, absolutely. And another thing that is important. But you don't want to have to wait to master that before you can create your first game where somebody runs backwards and forwards and jumps. Yeah. So definitely you need to know the underlying platform you're running, the hardware you're running, because you're writing a mobile game. But it's too process-intensive. It's going to drain the battery in a couple of minutes. So you don't want that experience for your user. One thing that Unity already takes care of is trying to write the optimized code for each platform you export to. However, you still need to know, as you said, like the underlying platform you're targeting. So how does that part work? You want this game to run on PCs, on Macs, on various phones. Do you have to obviously the code behind is the same? Yes. Unity has the ability to compile into those platforms. But you have to do the UI differently? That's an interesting question. You don't. We provide you tools to just like tell. You define your UI, for instance, in a certain way. And then Unity will take care of scaling and managing all those things. As you said, the code that you write is the same. Unity will take care of compiling to the specific platform. The only thing you need to do, basically, most of the time, is just tell Unity, OK, I want you to build two Xbox One, for instance. In this case, I don't have the component loaded. I need to go to the internet and install it. But it's super simple to do that. Cool. And then you may decide that your game is too busy for a smaller form factor. And then you might have to adjust it that way if the scaling doesn't take care of it for you. Another thing is, given the hardware differences between devices, if I'm running here, I might not care about my computer draining the battery because I can be plugged in. But if I'm on the cell phone, I am. So yeah, you need to take care of those things. Yeah, there are a lot of other components that you can understand if you want, if you're interested into that. But some of the other things you don't have to do. If you just want to have a lighting source, you put a light there, it will work, and you don't have to worry about that. So yeah, so you can grab Unity for free if you're starting. There is a personal edition if you want to try it out. Everything is unlocked, meaning that you can do whatever you use. The engine is not locked with any features for pro customers or anything. So you can just play around with that. Also, I know the audience is interested in open source platforms and open source projects. Unity itself is not open source. However, we are opening many of Unity's components. So the UI is open source. The networking is open source. Many of Unity's components are open source. So you can collaborate. You can see what's underlying the platform as possible. And if you wanted to, you could use Visual Studio Code to do the scripting as well, obviously. Yeah, yeah. You just don't get the nice tie-in from IDE to IDE. Right, right. So yeah, those are C-sharp scripts. So you can edit them anywhere. But if you want to have all the speed of development, that's it. It's also at Unity, it's available on Mac for authoring. So if you have Visual Studio on the Mac, the experience is going to be the same. So Visual Studio for Mac also ties in just as nicely. It works great. So it's important because before, if you were developing on PC and then you had to switch to Mac to do iOS development or something, you had to switch your environment, but now you can have the same stuff running on both platforms. Awesome. Yeah, yeah. So also we're announcing this partnership with Unity and Visual Studio. There's going to be a bundle there. So you can save a couple of $100 if you buy, if you get Unity and Visual Studio. OK, so if you already have Visual Studio, you can just get Unity, use it for free, and then at some point you have to pay probably if you're now selling games and whatnot, I would imagine, right? Yeah, well, so our licensing, it's pretty good, I think. You don't have to pay us anything if you make less than $100,000 per year. So if you're just, you can even make money out of your projects, you don't have to pay. After you pass that amount, you have to afford it. If I get to the point where I'm making six figures on a game, I'm probably pretty happy to pay. Yeah, I think that's fair. I think you'll pay, yeah, correct. No danger of that happening anytime soon. Yeah, but yeah, we don't charge royalties. So if you become a super millionaire out of your Unity authored game, you just pay your licenses, and you don't have to pay us everything. I think it's important. And then the bundle is the ability to buy Visual Studio and Unity. Yes, yes, that's the bundle. That's what you say. All right, so we'll have links to that in the show notes. We'll put some links to some tutorials and some getting started. I know earlier today you did some getting started videos is really good stuff on the Unity website for how you might get started doing this. And like anything, start small, do something simple, and then learn bit by bit. But it's a lot of fun. It is, it is a lot of fun. It can be a nice change of pace from writing the same old desktop and web apps. Yeah, definitely, it's a fun word. Cool, thanks for coming on and showing that to us. Thank you very much. All right, hope you enjoyed that, and we will see you next time on Visual Studio Toolbox.