 Hello, hi. I'm Abdul Ahmed. And I'm Sarah Sexton. And we're here to talk to you about Unity, the Unity game engine. Game development with Unity for the Mac. Yes. So we're going to cover two main topics. We're going to give an introduction about Unity in general. And then we're going to talk a little bit about what changed since we launched Visual Studio for Mac. So let's get right into it. We talked about that. So game engines. What are game engines? If you've been living under a rock for the last, I don't know, six years or so, then what are game engines? Do you want to tackle that? Sure. So game engines are a set of high-level APIs that helps game developers with graphics manipulation, with audio input management, with just anything a game developer would need. It's just a high-level APIs that would. So instead of for a developer to go down into the hardware level and program all of that, these things are extrapolated for ease of development. Yes. And with the Unity game engine, specifically, it gets coupled with a bunch of visual editing tools that helps non-programmers kind of manipulate games and levels and objects within the game without programming anything. Yes, Unity is a really fun sandbox to play in for programmers and artists alike. It's one of my favorite hobbies, actually. Just go in and play with that. And it comes with a really powerful C-Sharp tool where you can program things with Visual Studio and Visual Studio for Mac in C-Sharp and then have the Unity game engine consume that and you can play with it. Yeah, the partnership between Microsoft and Unity has been a very fruitful one. Yeah, for sure. So yeah, so let's go into a demo of how Unity works. Yeah, I'm excited to have Abdullah show you guys what we have in store. Sure. So here's Unity. We're using the 2D micro game, which is a learning tool that Unity includes within the installations of Unity. So I highly recommend it to use that and to learn how to use Unity. Right out of the box. Exactly. So if we look at here, let's just run the game right away and let's see how it looks like. So you can move left and right and kind of jump around and that's kind of how the game is set up. Did you have to wire any of this up before we started this? No, this game, this is just a demo. I just saw the demo and I opened it up and that's what I got. All the functionality was already wired up. Exactly. Okay. So if you look at the scene window as well as the hierarchy window, here is all the game objects that are included in this scene. You can think about a scene kind of like a game level if you're familiar with games. And every scene has a bunch of game objects in there and the game objects are the most primitive unit within the Unity game engine. Everything is a game engine. Everything is a game object. Yes, a game object, sorry. And then if you press on any of these game objects they get highlighted within the whole scene. So let's double click on the player here and here in the inspector on the right you can see all the different components that we added to this game object. By default the game object is transparent. It doesn't collide with anything. It's just empty. All it has is transform component which tells the game engine where it lives in 3D space. So when you were running the demo if you just kept on running to the right you would run through the walls because you were not colliding with the walls yet. Yes, that is true. So with this game object here we can see that there's a player controller script that's already pre-written. There's a sprite renderer. That's how we can see the sprites. There's an animator to animate that sprite as well as a rigid body and that tells the Unity game engine and the physics engine within Unity on how this object should interact with other objects. That have other rigid bodies. I've done a lot of game jams and I have to say it's really nice that there's already an animator hooked up because you can spend a lot of time just trying to get your main sprite character to face left and face right and have an idle animation and a running animation. All that's already done for you here. Yeah, exactly. It's a nice feature. And yeah, so that kind of how you manipulate kind of game objects within the scene. And if you look to the left here if you look actually to the main hierarchy you can see a main camera. And this is just like movies and within a scene there needs to be a camera just the camera that's taking images right now. And a camera is also a game object. Exactly. And everything that the game camera is capturing is what the player will be seeing later on. And this is if you go to the left here and see that game window this is what the camera within the scene is rendering. So depending on what platform you're on like if you're on a phone screen you want your aspect ratio to look like a phone right? Exactly. Or if you're on a Nintendo Switch you want it to be laid out in a more landscape mode. Can I say a fun fact about if you're doing virtual reality or augmented reality? Yes, please. Fun fact about that is you see here that your camera's background color is sort of this light blue with a solid color. What we do for example at Microsoft when we're making HoloLens games we set the background color to black because holograms are rendered in light and so black is the absence of light. So when you're looking through your game camera you're seeing the first person view and black is rendered as transparent and everything else shows up like in the first person view of you looking through your HoloLens or your mixed reality headset. Interesting. Does that make sense? Yeah, I learned something yesterday. So yeah, and then so let's familiarize ourselves more with a UI here. If you look down here at the project window here is pretty much just a file structure. This is what the files look like in your in Finder if you look at it. You can press on any of these actually right-click and reveal in Finder you can see your file structure in Finder. Do you know if you move the slider back and forth you can sort of change these from yes to thumbnails to files. Yes, exactly. Like this is very useful if you have a lot of images just to see the images right away. But sometimes if I like to put it that way just so I can see a lot more on my screen. So yeah, it's just for preference. Sure. So let's add a component and let's see how that looks like. You can add component either through Unity directly or create one through Unity directly or it can create one through Visual Studio which I'll show you how to do that. So let's create a script in under gameplay here right-click and add a new mono behavior. So mono behaviors are what is what we inherit in each script that Unity is going to be using. So let's create a new one. It just pops right up there into Visual Studio for a sec. Yeah, and it structures it the way that it needs. It starts adding the Unity game engine up there and let's rename it to test script. And if you look right here Visual Studio is actually telling us to rename it so we can just click that right away. Look at that. Yeah. So the Unity game engine has a bunch of different messages that they send to these scripts and they call them messages and you can add handlers for those different messages. So you can right-click and go to implement Unity messages. And here you can see all the list of different messages that Unity can send to your script. Examples of Unity messages. Look how useful this is. It's very useful. Sometimes I forget and go into documentation a lot like that's what I used to do a long time ago. Yeah. But now I can just look at this right away and implement. For example, on enter, on collision enter. So this is called when there is a collider on your component and I enter another collider. So there's a collision happening. So this function gets called. So that would make our character run into a wall or a platform. Like if you want the character to change its animation to be standing if it's colliding with the floor. So that's where we change that. Or falling animation if it's not colliding with the floor. Exactly. So that's how it works. But let's create some public variables here. Okay. Let's say public float. Is there a way to zoom in easily by the way? Let's see if I can zoom in into this. Scroll up. I can make the text just a little bit bigger. Let's do that. So public floats and let's call this offset. Let's create a public transform t. Now what's your thought process here? And now I just saved this script. Let's go add it to the player character here in Unity. So as you can see, Unity is working a little bit. It's Visual Studio sends us a notification telling, hey, we have added a script. So do your thing. Refresh Unity. Yeah. So if we go here and say add component, we can see that we can see our script over here. Your script, that's the one you just wrote. That's the one I just wrote. And if you saw this down here, you will see that our, yeah, you can see all the public variables that we created actually appear in the editor. Then that's really nice. That's a really great feature because it makes things more transparent and gives you some insight into what the script is actually doing, right? Exactly. And this also allows non-programmers to edit the game and play with the game without actually going back into the code. That is so nice. It's sort of like not exactly a drag and drop, but a more user-friendly way of editing the script without going into the code behind it. Exactly. I mean, we are going to drag and drop something right now. So if I take the player and drag it into the transform space here, the editor will understand right away that I'm trying to get the transform component within the player game object and put it in there. Now, in layman's terms, the transform and the player and all of that, that's just describing the XYZ coordinates of the player and we're transforming it, moving it from one spot to another spot. Exactly. That position, the rotation, and the scale of an object is what's inside the transform. If you look up here, you will see that these are, that's the information that's within the transform. Perfect. Yeah. So, and if we go to the script right now and edit the transform T over here. In the update method? Yes. So I'll explain what an update method is pretty soon. But if I update T right now, it will actually update, since I dragged and dropped the player transform in the editor, it will actually edit that player specifically. So I don't need to instantiate what is T within the script. Unity is handling that. So the update function within a mono behavior runs once every frame is being rendered on the screen. Depending on the game, if you're running your game at a 60 frame per second, it will run 60 times a second. Yeah. And if you're running at a 30, it will run 30 times per second. The loop that happens every tick. Exactly. So let's see. So let's try to edit T here within the game engine. Let me just restart this really quickly here. So we're trying to code things programmatically in intelligent ways, right? Yes. So here's the transform T. Let's look at the position equals, since the position is a vector of X, Y and Z. So we're creating a new vector 3. Vector 3 and 3, X, Y and Z. Exactly. That's the direction. So T dot position, that's the same position we're in. Dot X, which is the X coordinate. X coordinate. And then we're, let's add the offset. Adding an offset. And then let's keep the same, let's keep the same Y coordinate here. So they're not supposed to move up or down necessarily? Yeah, we just want to keep the up and down and just go horizontally. Cool. Yeah, we just want to modify the X coordinates. And since we're in a 2D game, we don't need to worry about the Z axis at all. That's true. Yes, the popping out from between you and the camera, that's a three dimensional problem. Yeah. So let's go back to the game and let's run the game. So before you had to press the arrow keys to control the character, right? Yes, that is true. And now if we see it, it starts to... I mean, right now we're not changing anything because if you look at the editor here and the specter, we... We haven't changed the offset yet. Yeah, the offset is zero. So nothing is really changing. But if we press zero, dot one, for example, there you go, that's the character moving. Well, he has a mind of his own. Yeah. And this is not the best way for this game to manipulate the character. So it's like a speed run. Yeah, but he can add like, you know, different numbers, just make it faster and faster. Or he can break your game. Yeah. So you can do all of these fun things and just play around with this demo to really learn what's going on and learn how to script things. And there's a lot more scripts here too that there are pre-made that you can look into. Some of them are for UI. Some of them are for the game mechanics. Some of them are for the gameplay. Some of them are for just managing the whole game as a whole. So go in, play around. Excellent. What a great demo. One of the things also that I want to talk about is how do you build your game? So within Unity, you can actually support all of these platforms. And they're very, they're very fun to play with. You can, you can target Mac. You can target iOS. You can target Android. Even Xbox and other platforms. And the HoloLens. Yeah, WebGL is one of my favorite because I can just build the game right away and send a link to my friends. Yes, it's so handy. Yeah, it's pretty fun. So that's kind of how you build your game using Unity. So you can build from a Mac PC to an Android phone just like right here. Yeah. Well, I'm impressed. Yeah, it's pretty fun. Let's see. So what other, what other things should we show to our audience? What about that window you were showing me earlier with the cable, the USB-C cable? Oh, yes. One of the cool things that, no, let's talk about the Raza Analyzer first. Okay, okay, first things first. Yeah, so we created... Who's we? Well, Visual Studio for Mac has the Raza Analyzer within it to help with diagnostics and Analyzer C-Sharp code. Tell me more. Yeah, so what we did is, what's included in Visual Studio for Mac right now is a specific Analyzer for Unity. So let's look into that really close. Let's just look at the code because that's the best way to learn, right? So if you said, for example, if game object, which is this game object and then tag equals equals player, we're comparing tags. We could show them where that is in the Unity editor. Yes, yes, we'll show that. But here, for example, this is a very expensive operation, but we know that as the Raza Analyzer knows that and it will recommend us to use the compare tag function instead of tag because it's a lot more efficient to use. So we can just use that right away. So it's suggested a more efficient way that was a less expensive call in the program. Yeah, and it will really help you make sure that your code is more efficient and running better. I want to know, how is it smarter than me? How does it know better than me? I mean, you're an amazing programmer, so maybe that's impossible. Oh, stop it, no, stop it. But yeah, so you can add tags to different game objects up top here. There's tagged, there's untagged, there's different tags. So this is what we're talking about with the player tag. Exactly. It's like you wouldn't name your floor under the player tag. You only want to save that player tag for your protagonist. Exactly. You can add layers and add different things. So the cool thing that we did too is that these analyzers are now open source. Yeah. Yes. So now any developer can go pull, edit the analyzers and even submit them for us. And that way the changes, any Unity developer out there can actually benefit from the changes that you make. Well, any Unity developer out there, is this special because it's like specific to Mac though? No, it's not just for Mac. It's Mac and Windows. So that's what's so cool about it. And any changes that you submit there are going to be available for all other game developers. The power of open source. I know, right? And one of the cool features too that I wanted to show here is actually how is attaching the debugger to different processes. So one of the things that we added was, or Visual Studio for Mac added, was the ability to attach to multiple different, it will show you multiple different Unity instances that are running. Do you have more than one Unity instance running? Yes, I do. I got this one here and this other one here. Oh, that is, that is clever. Yeah. And now within Unity, within Visual Studio you can choose which instance of Unity to attach your debugger to. Very nice. Yeah. And one of the cool features also that I figured out with Android phones is that you can run your Unity game on your Android phone and then you can plug it. And it's all just happening right here. And you can see the game. Look at that, it just popped right up. Yeah, on your Android phone just pop up right away and that way you can debug your Android game. Yeah. Running on your Android specific device, make break points and look at the debugger and yeah, and fix your game. This is some cross-platform magic happening right here. I'm really excited about this feature. I really love Android. I have a Google Pixel phone also. So yeah, so we added a whole bunch of other features too to Visual Studio for Mac. For example, we added the feature where if you save your script, then we just send a message directly to Unity so Unity can start consuming that script. And we don't have to go back to Unity for it to start processing that script. We also added, so we also made it so that by default, Visual Studio for Mac doesn't compile the whole project because we don't need to do that. Unity is handling the build process. So we don't really, Visual Studio doesn't really need to do that and that sped things up quite a bit. Oh, nice. You can disable that behavior if you want from the preferences but that by default that's the behavior. The faster the better. Yes. Also the debugger that we have for Visual Studio for Mac now is the same one that's in Visual Studio for Windows. We took that same debugger for Unity and we moved it and we ported it completely to Mac. That was very exciting and it made it a lot more powerful. Oh, okay. Yeah, we added a shader highlighting too so if you want to edit some shaders, they're going to get highlighted within Visual Studio for Mac. We also added pointer support in the debugger. So if you're running on safe code, you can actually debug. The unsafe code. Yeah, like those like memory locations. I'm not that most expert on that but I usually like the safety that C sharp. I would love it if you could show me a little bit more about shader highlighting like just a teensy-weensy little tease of shader highlighting. So a while back, when you open up a shader file, it'll just show in black and white with no highlighting. So like- But now- So the colorful text is the new part. Exactly. That's the text highlighting. Yes, it makes it a lot more readable and developers can develop a lot more easily. So this is a new feature. Shader code a lot more easier. Didn't used to be there. Yes. And we added that recently. Oh, very cool. So yeah, so- I like it when things are colorful. I know, I know. It makes it a lot easier. So I think that's it for a demo. Do you want to see if we have any more questions out there? Yeah, would now be a good time to head to questions. Sounds like great to me. First of all, thanks for presentation. It was fantastic. It's great to know that you can all- So use Unity to build stuff on the Mac and what I'm not sure about is how many platforms you can target. Like is there a specific set of platforms that we can run these Unity solutions? The build editor. Sure. Let's open up the build settings here. As you can see, it supports PC, Mac, and Linux as a standalone application as well as Android, iOS, TVOS, and Xbox, PlayStation, and I know Nintendo Switch is supported. Yeah, we're missing some from this list. This is a stable version of like a long-term support version of Unity, but if you install a much more up-to-date version of Unity, you can see a lot more platforms being supported too. Does this have something to do with when you're installing Unity from like the installer from the very beginning? There's like a list of boxes you can check of what do you want to have. Exactly. That also is an option for you to install support for all of these platforms from there. Yeah. And so, yeah, and there's a lot more people adding support for their platforms every now and then. And so, it's important to follow Unity's news and see if any new platforms are supported. Yes. Great. We have one question over Twitter, which goes on the Rosen analyzers that you touched earlier on. The question is, can I create my own Rosen analyzers for Unity now that you've open sourced these analyzers? The answer is absolutely. Yeah. Yeah, that's the point, right? Yeah, exactly. Extend and open source. That's fantastic, right? You showed some assets there for creating games. I think people would like to know how to get assets or if they're not good with designing and artwork. Is there a way for us to, you know, common developers that are not really good at designing stuff to get started and write games without relying on a designer? Sure, yeah. You can just, the thing, the cool thing about Unity is that they know that while people are learning how to make games that they don't usually have access to resources, artists or anything like that. So they have created a store. Yeah, the Unity Assets Store. It's really a very helpful tool. The Assets Store is always there for you. And this is different from just when you're creating a new project in Unity and selecting either a 2D or 3D game, you have the option to have game assets downloaded. But if those are defaults, if you want something more specific to what you're looking for, you go to the Assets Store and then you can search for things here. And you click the button. Do you want it to be free or not? And so continue browsing. Yeah, I mean, there are scripts to handle UI, to handle different controllers. For example, I know that supporting or hot swapping different controllers on consoles can be very troublesome and very expensive to fix by yourself. But there are plugins out there that will handle that for you. There's plugins there that help you with... I just saw something that's relevant to you actually. I think it's VR Chat. So that might be helpful for HoloLens developers too. And sometimes you can find just asset kits. For example, if you want to make a fantasy game and you just want to get started right away, maybe you'll change that later once you get more resources. But right now you just want to get started right away. Placeholders. Yeah, placeholder is anything like that. There is a bunch of different assets here. The abundance of them. Yes. And if you're a developer and you are trying to find a way to monetize some of your artwork, or perhaps you're an artist, if you sell your assets in the Assets Store, that is another way to generate a source of income. Yeah, not just assets. You can sell your scripts. And scripts too. Just program all of them with a visual slider for Mac and then put them up there. And that's how you can make money. Yeah, great question. You can build games, make money. What else do you want, right? One last question and we're done. Are there any plugins that you recommend or you have some favorites for Unity to make game development easier? Sure. I mean, one of the ones that I really like, if you're still not the most confident in your programming skills, Playmaker is a really good one to help you with visual programming. And then you can go in to look into the code and see how things are going and learn more about that. So that's a really good one. Rewired is another one for controllers, which I really enjoy. It really helped me a lot when I'm developing games with game controllers and people who are hot-swapping controllers and just manage all of them. Do we have time to read or maybe pull up a page about Playmaker or? I think Playmaker is right on the front page. It's that popular, it seems. Front page of the Assets Store right now. And that can help you. You can purchase that and play with it. Yeah, another good one that I really like is 2D Camera Pro. I think it's called 2D Camera Pro. Or maybe it's Pro Camera 2D. But that helped me a lot with, yeah, there you go. That helped me a lot when I was starting to develop my game. And it handles things like zooming in when I'm talking to different characters, staying within the boundary of the game, and all of that heavy lifting that you have to program all of that within your camera. But there are people who made those scripts already. And that one's specific to a two-dimensional game? That is specific to a two-dimensional game. But there are so many Assets out there and you can go and check out different ones. Another good one that I like, I like story-driven kind of narrative games. And there is a plug-in called Fungus, where it's open source too. So it's free and you can play with it and you can make narrative games. So kind of like a visual novel sort of? Exactly, yes. Very cool. Yeah, that's very cool. Awesome. Yeah, great job on this, man. Yeah. Very polished. Thank you. There you have it, my friends. We showed you how you can use your .NET skills on a Mac to write games with Unity. It's fantastic that the ecosystem is so open and you can find plugins. You can find Assets so you can get started easily. Before we move on to the next session, which is all about mobile apps with Xamarin.NET, we're going to take a quick break. So we'll see you in a couple of minutes. Thank you very much. Stay tuned.