 Welcome back, and today I'm going to be talking about Unity. My name is Christos Matskas. I am a product marketing manager for Unity and Mobile. And I have a really great interest in this product. You probably have had a lot of announcements throughout the two days so far, so .NET Core, Visual Studio, and Visual Studio for Mac. So today, what I want to show you and why I wanted to pick up this session is because I wanted to showcase that with .NET, you can build some amazing things, including games, right? Our agenda for today is very simple. I'm going to introduce Unity to you just to let you know what it is and what you can build with it. And then I'll show you how to get started if you've never done Unity gaming before, like I haven't. So it's a great experience to see how you can set up your machine. Then I will show you why you want to use Visual Studio or Visual Studio for Mac to write your games. We'll do a few demos just to showcase the capabilities. And finally, we'll talk about why Visual Studio is so well aligned with Unity and what makes it such a great product for debugging and writing your games or your 3D real-time applications. And hopefully, at the end, we'll leave you with some learning materials and set you up for the next few sessions of the day. So getting started, Unity, of course, is the most widely used real-time 3D framework, right? It started as a game engine, but now they're targeting different industries. So their goal there is to give you the tools to create applications for not just games, but 3D real-time applications. They're the most widely known engine and it's built on .NET. So if you're a .NET developer, there's nothing stopping you from writing games starting today. And the nice thing about Unity is that you don't just have one platform, but you have over 25 different platforms, whether you want to develop games for Xbox, whether you want to build solutions for the run on Windows or Mac OS. Obviously, mobile is very big. Mobile games are fantastic these days and many people monetize on that. So if you want to build things for that, then that's also there. TV OS, the platform is insane. So taking your .NET skills with Unity and our IDs means that you can build almost anything for any platform out there. And getting started, obviously, the first thing that you need to do and you need to be aware of is that ever since 2019.2 version of Unity, things have changed quite a bit on how you install Unity. So there are two ways to get started with Unity. One is you go to the Unity website and you download the installer and it allows you to actually go and get the bits that you need. So it's a Unity first experience and many developers that know Unity will start from there. But if you're already a Visual Studio developer, there's a way for you to add the Unity workload to allow you to get started. So we'll see how you do both. So if you're inside Visual Studio, you select the game development with Unity and that will download the Unity dependencies for you. And the other way around, if you're already on Unity, then you can go and add the components that you need. So if you are on Mac OS, then it will download the Visual Studio for Mac components. If you're on Windows, it's clever enough to let you know that you need to download Visual Studio. So I already have both the installers here. So if you're in Visual Studio installer, you're just going to modify. It kicks off the modification of the latest version that you're using. Today we're using 16.3, which is the latest and greatest. And if I scroll down here, you'll find that I already have selected the game development with Unity. If you don't have it selected, you add that and it will bring down all the necessary dependencies. So I can close that off. And if I go to the Unity Hub, up until this point that didn't exist, so you would download directly Unity and get started. But now they have a Unity Hub like the Visual Studio installer and allows you to add multiple versions of Unity because certain things may not be working with the latest version of Unity, especially their component engine. So here you just come to install, you add your installation and then from here you can also add modules. So in this instance, you'll notice that we already have the Unity game development checked in because we went from the Visual Studio workflow first. But if you don't have it, if you start with Unity, then that's the way you get started. And that's all you need. As soon as you do that, if we jump back to the slides, you'll notice that there are certain things both inside Unity and the Visual Studio installer that show you that everything has been configured correctly. So we're ready to go with these ones and what this one is telling here for the external tools is that if you are working with Unity and you are on Windows, it has already recognized Visual Studio 2019 as present and I've already checked in the editor attaching because one of the big things that you want to do is as you write your code for your games, you want to make sure that you can debug the code. And you want to do it in Visual Studio because it's the best editor out there. So next we're gonna look at why would you want to use Visual Studio or Visual Studio for Mac over say Notepad or OneNote or whatever. There are, if you've been developing for a long time with Visual Studio, you probably know some of these capabilities but if you're new to Visual Studio or if you're just focused on Unity, then I would like to highlight some of the big features here. Obviously refactoring is big as your code grows, you want to be able to quickly jump into the code and change things, move them around, clear your code and what have you. So you can always use the mouse and right click on the line or you can instantiate the command by using control or command dot. You can go straight to definitions. I will show this in a demo very quickly. You can navigate to the compile assemblies. You can get suggestions for variable names. The ID guides you through a lot of good practices and would try to give you the tools that you need to build good code. So if you're creating a method that you want to duplicate, for example, then we can quickly do that in the code. There are a lot of tools there to make you more productive with the scripting in your games. Multi-caster mode, editing, we got global search and that's very big because if you have a big code base as your code base grows, you want to be able to quickly search and find different components in your code. Going to enclosing block, if you have big blocks of code. And finally, whether you're working on Visual Studio or Visual Studio for Mac and you'd like a specific set of bindings, then we also give you the ability to actually switch the bindings around. So if you're in Visual Studio for Mac, there's a setting there that tells you, I want to use my Visual Studio key bindings and since I have both machines as well, I like to have that consistency across the two IDs. So you can do that as well. Next one we have IntelliCode. Some people may already know IntelliSense and IntelliCode is the next level. It's the AI guided IntelliSense that you get inside your code and it's always context aware as well. I will do a demo on how IntelliCode works and how it can improve your game coding. Visual Studio LiveServe, this is a life-changing experience because up until this point, you maybe have been developing in teams or developing in isolation and you always get stuck, right? There's always the internet but there's nothing as somebody out there that can help you out. So using LiveServe, you can actually set up a session to serve your existing coding environment with somebody else. So there could be somebody sitting three hours away from you watching TV on the surface go and then you call him and say, I'm stuck with this solution here in my game. I don't know what to do. Can you help me out? You can actually spin up a session inside Visual Studio. They could be sitting on their sofa playing with their Visual Studio code, doing some web development. They don't need to have the exact same setup. You'll be setting your environment. So LiveServe allows you to unblock, it allows you to serve your environment and find solutions to problems. Sometimes you can use that for as a learning experience as well. So that's really important. I will show you how to spin up a LiveServe session if you want to. We have built-in source control. Obviously if you're using Git and most people these days tend to use Git and we do have built-in ID support there. We have real-time code analysis. That's very important as you write your code. You want to have real-time feedback. You don't want to have to write your code, save it and then build it only to find out that something is not as you would like it to be. That also includes some of the things that I'll be talking later like roles and analyzers and getting immediate feedback about the quality or the errors in your code. Editor config is very big. Lots of people talk throughout the conference so far about editor config and how it ties very well with Visio Studio or Visio Studio for Mac. And for those people that have not used editor config before, it's a way to actually define a code, how the code should look and behave, how you want your variables to be declared, how you want your spaces and tabs to be declared in your code if you want to go down that route. And because it's a file that is checked into your solution, it follows the code everywhere you go. So if a new developer joins the team, then editor config allows them to pick up the exact same code habits if you want and apply them to their code base as they code. Code lens gives you a very quick glance about how your code has changed over the times and over the years, how many check-ins you had for a specific method and what have you. And then some other capabilities is obviously if you're changing across machines, if you work at the office and then you come home and you pick up the work, you can actually synchronize your settings for the IDs across those devices and across those environments. So you can have a consistent Windows layout, you can have a very consistent look and feel. So if you prefer dark themes, then that's how it works. And then we have custom screen layouts which you can save as well and then take them with you. And if you didn't know, we're at the support light and dark themes on your ID to make it look and feel as you would like to. So next I'm going to jump to a couple of demos and we're gonna talk about some of the things I have shown you already. So moving back to my code and we have talked about refactoring. So usually when you are sitting in your ID you can control dot and then you get intelligence and says, we can remove those usings and make sure that you don't have them anymore. You can also fix on all document or projects and all solutions. So if you're brave enough you can apply that setting across the whole solution. So let's do the document over here. You'll see it says I can preview your changes and then you can apply them. We have things like, let me do another one. You can see here, again, we have fixes. We talked about the multi-carat editing. So if I were to say add new methods I could do control out dot and then select multiple locations or control shift dot, sorry, control out. Select one, two, that seems to not working. Okay, I'll move on. But we can also do multi-line editing. So if you're here and you want to change from private to public, you can go public and automatically applies. Again, we do support multi-carat editing across the files but let me change that back to private. We don't want to break our code. Okay, so this one, I did talk about editor config and the easiest way to showcase these is by jumping to my files, let me just see desktop and I already have an editor config. The easiest way to get started, I find, is if you jump to the Roseline repo on GitHub they have already an editor config that is pretty well tweaked so far. So as soon as we drop the editor config there you'll see we have all these different settings. Obviously you can also change them to fit your team's needs and that means that if you want to break or if you want to go from a warning to an error then it allows you to go that. So you can see here the severity set the suggestion but you can change it to error and then that will cause everybody to actually go and fix their issues. But if I go back up, I'll pick up something that's very well debated and heated conversation. So if I go with tab and save that, saving, I was thinking about it, there you go. So if I switch back to my code, you notice that I right now have four spaces everywhere but if I do control K and control D automatically applies the editor config settings to my code. That means that as soon as you add your editor config you can go back and apply those settings to your files which is fantastic. That means that your team can have a consistent code base there. So let me just don't save that one obviously. Let me just go back and revert that because I'm pretty sure my team will be upset about the tabs. Space, save that and again that applies. I did mention about LiveServe. So if never use LiveServe, it's available on VVisitio and VVisitio code. You don't have to have the exact same environment on the target machine, the one that you're setting with but you can go into LiveServe. It's already kicked off a setting session. I don't have anyone right now to share with but if I go into more info, you'll notice that it says just copy this URL, send it to somebody else and with that they can actually join your session and share exactly what you see here. Which is fantastic especially if you're in games development and you're new and you need support throughout your coding session. So I'm just gonna stop that live, sir. In case anybody wants to join and I'll go back to some of the other things I talked. So let's see here, what else do we have? CodeLens, we're building source control. Yeah, let me just show you this one. So with source control again, it will automatically pick up. I was using git locally here so you'll notice that there's a lot of files that have changed throughout my editing. You can also use an exclude, so git ignore to exclude some of the files because obviously you don't want to check in everything on your source code and like in dark themes with the settings. If you didn't know, you can create custom settings as well. So if you want to have a very specific layout for your games development, you want to ignore your debug, you want to ignore other things that are not relevant to you or windows that are not like toolbox then you can come here, create your session, your layout and then you can apply it. I know where you are. These settings do carry with you as soon as you log into Visual Studio with your account. So if I were to change to a web layout, we'll ask me whether I want to do that and then it does it. There you go. It's very different, right? I want to go back to my default one because I don't like this one. I should have created one for Unity obviously, but it's fine. So I'll go back to my default layout. There you go, applying this one. Fantastic. Anything else we want to highlight here? And in telecode, I will show you in a bit and I will explain why real-time analyzers. We have Roslin, if you don't know about Roslin, you can download and install Roslin analyzers. The ID also comes with some default analyzers here. As I type, it might come back with a suggestion saying, you're missing an underscore prefix or you could make this field read-only. So straight away, it actually tries to make me a better developer by providing some suggestions for my code. And Roslin analyzers are very powerful because they run at real-time as you type your code. So you don't have to again, again, save and build before you find out that there are some warnings against your code. Right, moving on, I want to highlight why Visual Studio is so important with Unity and why when you use them together, they set your code on fire, right? You become a lot more efficient. Obviously, in telecode now has been designed to work with most of the CSARP default projects, but our team is working to bring the Unity API messages into Intel code, which means that we're scanning our code bases out there to make sure that we pick up the best skills for your Unity games. And Intel code goes one step above IntelliSense because as I said earlier on, it's context-essensive. It knows exactly where you are and what you're doing and will provide you with the best ideas as you type. Visual Studio does come with superior debugging. We have the ability to set up trace points and break points and really dig through the code. There have been already sessions that show advanced tips and tricks on how to debug using Visual Studio, so I would urge you to go and see these. We also added a Unity Project Explorer, which makes your experience slightly better. So if I switch back to my Visual Studio, you'll notice that, I don't have it down here, but if I search for Unity, you'll notice that it has Unity API reference and Unity Project Explorer. So that brings up, it gives you a more simplified version or a look and feel of your files and your assets so you don't have to go through the standard solution explorer, so we have an optimized experience for you. Attach and play, going back to the ID. Up until this point, we only had Attach, so you had to spin up the game and so you had to spin up the Visual Studio, Attach to Unity and then you had to go back to the Unity Editor and spin up the game and then set break points here in order to be able to attach. But now, lo and behold, we have Attach to Unity and play straight away, so you will kick off your game end to end. So if I were to try this one and we can also put a break point over here, we'll kick off my awesome game. It's not awesome, but I did spend an afternoon writing this game, so I wanted to prove to myself that as a .NET developer, I can write something in Unity in not a lot of time. So within one afternoon, let's say four or five hours, I was able to put this thing together. So let's see if it's already kicked off. The break point is there. If I'll go to my game, trying to switch now. Right, let me stop that one. Bring it back to focus, I think it's, right? Something, something, resolution, something. Okay, so that's my game. It's a very basic game. I created a car and I put some obstacles on the road and what I'm trying to do is circumnavigate around them. So I had no knowledge of that. I've used some ready-made components, so Unity makes it very easy to actually create a whole world out of ready-made assets. So all you have to do literally is write the experience or the behavior around these objects and how you want them to behave. Right now, before even starting coding anything, these were just dumb objects sitting on our scene. So what I did is actually add user controls to be able to navigate around the car and then I wanted to also add the behavior of moving the camera behind the car, so it follows the car as it goes through. And later in the game or in my talk, we're gonna add one behavior which is exploding crates because there's no fun, there's no explosion, right? So I wanted to make sure that if you touch the crate, it just explodes. So right now we're here, you see it actually has kicked off the game. So I can see, I think, there you go. We can navigate around the space. It's very basic. I saw them to my daughters and they were not very impressed because they play Xbox and then when I saw them this, I was really excited, but the excitement not really panned out with them. So as you can see, I can already control it and the code that I needed to write to make this happen was literally a few lines of code. So in this instance, we have four lines of code that control the forward and backward and the sideways movement. And then one more line of code that actually allows us to control the camera. Now I did speak about IntelliCode and how it works for us. So if I were to do transform here and then do a dot, you'll notice that we do have position, local scale, parent, local position and rotation. It's the IntelliCode here. It tells us the code that you might want to use this first because these are the most common ones in the context of the update. So maybe you want to pick these ones up rather than try to find through the API. As you can see, it's a massive API here. I have no idea what I need to do. So IntelliCode really helps me focus on the things that really matter. And the nice thing about that is that if you go into an if statement, then it will actually change the whole experience. So let's say if I go down here and say if and then transform and dot. You'll notice that it's changed slightly. So it gives us the root, which was not there before. It also gives us a child object. So it looks for like if transform has child objects, you might want to do something. So IntelliCode hones in into those parts of the API that do make sense to you. Right, I did talk about IntelliCode, yes. And one more thing about IntelliCode, right? We already have the automatic IntelliCode which does a lot of things out of the box for us. But you can take it one step further by training IntelliCode to apply specifically to your code base. So if you search for IntelliCode up here, IntelliCode, you'll notice that there's IntelliCode model management. And what this does is allows you to submit your code to our IntelliCode engine to create the model that you need to apply to your machine. And that makes it very specific to your code base. You can also share that with the rest of the team. And that makes everybody more efficient. So if you have a large code base with a lot of classes that you want to be able to quickly bring to the surface then IntelliCode allows you to do that. And you also have a custom model for Unity to allow you to even be more efficient. Right, by jumping back into our Unity. Last thing I wanted to do is obviously show you some of the good things in Visual Studio. We do have the ability now to create C-SARP files, Cader files and Inam files directly in the Unity project and the Explorer, faster project reloading. So we want to make sure that as you change your code from Unity then the project reloads much faster, especially if you add a lot of assets. We want to have reduced time for debugging. So not many delays. The team has really focused on better performance. We also want to support more unsafe code debugging options and we have Unity specific analyzers and diagnostics inside Visual Studio to make you look better and have better code. And finally we're suppressing non-applicable C-SARP diagnostics. So with that I wanted to go back to our game and just add the explosion because as I said, I promised you explosions so we'll see some explosions. This time I'm going to go via Unity. So here you'll notice I have an obstacle which I'm actually using to create lots of obstacles in our game because we have about six of them. It doesn't have any behavior or code. So what I'm going to do now is add a component. And in this instance we're going to add some C-SARP files so a new script. We'll call it collision detection because it's actually colliding with something. Collision helper, there you go. A new script, collision helper, create and add. So this will add it to our obstacle. Now because everything else in our code base inherits from that base obstacle, all I need to do now is go into our where did that go? Oh, it's still loading, right? Okay, still fixing it, adding it. There you go, so the collision helper here. Now that file is here, let's tidy up a little bit. We won't have a nice tidy solution and I'm going to jump into my collision helper. This will open inside Visual Studio. I'm going to delete these ones because I don't need them. And I'm going to add my snippet. So what we're doing here, very basic, took me probably two hours to figure it out, four lines of code and there you go. What we're doing is we're getting the game object. We need to make sure that it's only the vehicle that collides with our crate, right? Because if everything else collides, then we don't really need to know about that. Then we grab the particle system that actually throws the explosion. We make sure that we have a handle on that. In fact, I've used the curly brackets that Mad stocked on the first date to check whether it's new or not. And then we need to make sure that it's not playing right now and then kick off that destroyment. So I'm going to kick off the game now. Let's save this one. Then kick off the game, blow something up and then we can move into questions. There you go. It's gonna take a couple of seconds, explosion, right? That's it, four lines of code and you have an explosive crate, right? Last slide for me for today is all about what you can do next. So if you are keen on learning what you can do next, we just go and download Visual Studio at the Unity. We recently learned some amazing learning tutorials with Unity in collaboration. So go there, we have more than six hours of learning materials. And then we also have how to build your first game. Our PM, John Miller wrote this one. It goes through step-by-step on how to use Visual Studio for Mac and build your own tic-tac-toe game. So thank you very much for joining me today.