 Okay, so now we are ready to set up the logic for the UI screen in our UI system, now that we have the UI system ready to go, and this will allow us to turn on those lines of code that we commented out in the UI system. All right, so let's get moving and switch over to Unity, okay. So let's pop open that UI screen script here, perfect. Okay, so the first thing is that I want to set up. So every screen, okay, and you're just going to have to take my word for this, every screen in our system needs to have a couple of required components. So the first one is going to be an animator, all right, because I want to have animation on my particular UI screen. And this is to make it so like UI elements fly in and out, or maybe they just fade up and down those kinds of things. So we are going to set up an animator, a base animator for all screens in a later lecture here. All right. So then the next thing I want to do is say require component type of canvas group. So the canvas group allows us to control the transparency of any UI element that is actually below this particular screen. So it's super useful. And that's why I always attach a canvas group to every UI screen that I have in my UI systems. All right, so with that, that means that we need to actually capture. So I'm going to create another private variable. We need to capture that animator, all right, or store it as a reference. So I'm just going to create another variable, a private variable. And that also means that in the start method, I want to get that. So I want to say animator.getComponentAnimator, or type of animator there, perfect. So that'll store it. And because we put this required component up there, we can be insured that we will have that component on it. So the next thing I want to do is I want it to be able to set a selectable. So if you're not familiar with what a selectable is, any UI element here inside of Unity. So let's take a look at the button down here, this register button. You'll notice that we have this button script. So this button script actually inherits from what is called a selectable. So what this does, by us including a start selectable, we can automatically highlight a button when a screen starts. So you see that a lot in games and in apps as well. Like when you go to the start screen, the play button is automatically highlighted, or it's automatically doing its animation, saying, hey, click me kind of thing. That's what this is going to do. So what we're going to do is we're going to say, I'm going to create another header for main properties just to make things clean inside of my inspector. And we'll say public selectable. But in order to actually do that, we need to include the UI namespace. So we're going to say using unityengine.ui. OK. And so now we can say public selectable. All right. And we're going to call this mstart selectable. And I put the m underscore in there because that's the Hungarian notation and it stands for member. So whenever I search for variables or properties of this particular class, I can just type in m really quick and I can see everything right away in the intelligence. So it makes it a lot easier to find stuff. All right. So now I want a couple of events on this as well. So I'm going to say using unityengine.events. And this allows me to put the events just like we did for the UI system there. And I can say these are the screen events. And we'll say public unity event onscreenstart. So anytime the screen starts, let's fire an event because we might want to fire off some other stuff. We might want to have an audio cue play or maybe a particle system like I was saying before. So and then we're going to say onscreen close. OK. Equals a new unity event. Just so we can actually communicate with other scripts without having to create more and more code, we could just use these events to communicate with other objects. And you'll find after using events there or at least unity events more and more, you'll find how powerful they are and how it makes your code reusable and a lot easier to understand and manage really. So that's why I like to use them. All right. So now, again, for screens, we don't need the update method either. But what we want to do in the onstart is we want to say if we do have a start selectable, OK, we need to set the event system to or we need to tell the event system, hey, we have this selectable, so highlight it. And in order to do that, what we need to do is include the unityengine.event systems namespace as well. And what this will do is it'll allow us to access the event system.current. Oops. All right. And that is literally this object right here. That is literally that guy. OK. So if you have that in your scene, this event system.current will return a reference to that particular object. So we'll say event system.current.setSelectedGameObject to our mstartselectable.gameObject. And what will happen is it'll trigger that particular selectable, that button or whatever, right? It'll trigger it and tell it to highlight itself, right? So if I were to select this button, what it'll do is it'll set it to the highlighted color. Or if you have it set to sprite swap, it'll set it to the highlighted sprite. Or animation, it'll set it to the highlight animation. All right, so super useful to include that in your screens. OK, so we're starting to build this puppy up over here. All right. So the next thing that we want to do is put in our two helper methods. So we're going to say public void. And I'm going to make these guys virtual, because we are going to extend these later on. Because we're going to get all fancy and stuff. We're going to say startScreen. And then we're going to say public virtual void closeScreen. All right, so we're going to startScreen and closeScreen. So the first thing that we can do that we know we can do is fire off our events. So we're going to say if onScreenStart, which is not equal, no, if we have listeners in this event, meaning objects waiting for this event to happen, we're going to say onScreenStart.invoke. Perfect. And we're going to do the same thing for the close. So we're going to say if onScreenClose does not equal, no. We're going to say onScreenClose.invoke. Boom. OK. So with that, we actually have most of our screen set up. The last thing that I really want to do is fire off or trigger a very specific trigger property on an animator. So what I'm going to do is I'm going to say if we have that animator, if animator, OK. So if we have that particular object, we're going to say animator.setTrigger. Oops, we want trigger instead of target. And we're going to say show. And then for the close screen, we could say hide. And you'll see once we get to the animation portion of this course, how useful that is. Now, one thing to note, we could actually make that even smaller so we could refactor that a little bit. We could say void handle animator, OK. We could pass in a string called a trigger. And instead of typing this out twice, like all these lines, OK, these four lines like that, right, instead of typing that out twice, we could just say a trigger, all right. So now I can get rid of these guys, like so, OK. We could say handle animator show, like that. And then down here, same thing, right. Much easier. Same code. Now, basically we don't have two opportunities where the script could fail. We just have the one, right. So if there's an error here, it'll happen here and not in two places. Cool. All right, so I'm going to close out this video here. And in the next video, we are going to start to get our fader set up, all right. Because we want to be able to also have the ability to fade between both these screens automatically, OK. So let's get going. Thanks so much.