 All right, so let's keep on moving with this guy. We do have the camera working. So what I'm gonna do now is walk through the process of building a basic editor tool. I mean, we're gonna look at some, like I would say intermediate stuff when it comes to editor tools for these types of components. But I really like to do this for most of my components. And the reason why is because it allows other people who may not be a programmer, right? They're a designer, they're an artist helping you out or something like that. Use your components, right? It makes it really easy to understand instead of looking at your default Unity Inspector editor that all components, all mono behaviors are given basically. So let's jump over into Unity. All right, so now we're over here inside of Unity. Awesome. What we're gonna do now is open up that other script. So inside of the editor folder that we created, let's go and open the top-down camera editor. And let's take a look at how we stub in an editor script really quick here. So first things first, like I was saying, I always like to put these under my namespace. So I'd call it indypixel.cameras. All right, and any other camera basically that I create from here on out basically will be underneath the indypixel.cameras namespace. So basically protects everything. All right, so we're not gonna need these methods for editor scripts, but I do want to make my regions first here. So variables, and then we'll have our main methods, like so, all right. And whenever you're making a Unity editor, you have to include the Unity editor namespace, all right? So that's where they keep all their code protected, right? So all their functions for editor stuff. And then we have to tell this class that we want it to be a custom editor, and we have to give it a type, but now that type is gonna be what we want to override the inspector for. So in this case, it's gonna be IP top-down camera. All right, and then finally, we have to inherit or extend from editor. Boom. Okay, then finally, well, not finally really, we still have a long list to go here. We're gonna do the target. So we wanna store a reference to our particular object that we're editing. So I want to do the top-down camera, not the editor. So camera, I'm just gonna call that target camera, like so. Cool. Okay, then because we extended from editor over here, what we can do is we can override some methods that come with it. So I'm gonna say public override. And then we want on Inspector GUI. You can see how many there are. I will leave the base in there for now because I don't think I'm gonna do anything with the actual, excuse me, the actual inspector. So if we were to actually click on this guy here, I'm not gonna do anything with this UI. I just wanna add some UI to the scene view. So that's fine for now, which means you don't even need to do that, but I might actually later on go and add and customize that inspector, so this guy right here. But for now, what I'm gonna do is just focus on the scene view GUI. So I'm gonna say void on scene GUI. And this allows me to draw into that scene view, okay? Allows me to draw into here. So let's do a quick example, just to prove that. So I'm gonna say handles.draw solid disk. All right, so you notice that it needs a center. That'll be our target. So I'm gonna do target camera dot mtarget dot position. Okay, and we should also make sure that we should say if not target camera dot mtarget, we're not gonna draw anything. So we'll do that return statement again. And then you don't have to keep your brackets down here. We can always, you can always get rid of the brackets, right? And just have that right below. But for readability reasons, I always like to do this. Hold on a second. Oh, I just need this, let this thing compile. There you go. All right, so then so mtarget camera dot mtarget dot position that we need a normal. And the normal basically means the direction that this disk is gonna be pointing. So I'm just gonna do vector three dot up because I want it pointing upwards. And we'll give it a radius of target camera dot. Oh, I forgot one step here. So, excuse me, we need to back up one second here. So in our main methods, we also need the void on enable because I haven't even captured basically. I haven't pulled in a reference of the object that we're editing. I just set up the target camera. So I need to say that the target camera, all right, so the target camera is equal to target like so. And we get this target variable, right? From the editor namespace. So they provide that to us. And that holds the reference to what we're currently editing. So I need to also cast it to the proper type. So now I can do target camera dot mdistance. Oh, and I made them. That's right, I made them all private. So again, one of the reasons why you could probably use a serialized object, but I don't have time to go through all that. I am gonna be making a whole series on, let's just do this. I'm not going to access those guys. So I'll leave that as that. I am gonna do a video series on more advanced editor scripting where we actually use serialized properties and serialized objects and stuff. I just wanted to show how to make it really quick. So we're gonna do mdistance like so. And the radius for this is, oh no, that was the radius, sorry. There we go. Cool. So now let's take a look at one and see what we get. Boom. We now have a disc in the scene. It's not very cool though, because it's hiding our tank or our target. So that's a good place to start. What we wanna do now is we wanna set it up so that basically we can pull a slider in this 3D view in the scene view here and it actually changes the distance value. And now the reason why I'm drawing a disc is because if you were to just look at the distance from the top, it's just the radius of a circle all the way around. So it'll tell us what the distance would be at any point in the angle. Okay. So let's go and I'm gonna store a reference. So I'm gonna say transform. And the reason why I'm doing this is because I just don't wanna type out target camera dot mtarget all the time, right? Transform. And I need this to be camtarget equals, there you go. All right, so I'm just storing that there. Okay, so storing target reference. And it's just so I don't have to type that out all the time. Now I can just type camtarget. Okay, so what I wanna do is keep the disc here. Okay, but I do want to give this a better color. Okay, so the first thing I'm gonna do is draw a wire disc here. So we're just gonna switch this over to wire disc and then I'm gonna change the colors of the handles. So I'm gonna say handles dot color is equal to a new color and we'll give it like a blue. I think that's what I had in the, I'll make it really light because I want this to be very, very transparent, solid disc. Okay. And all that stuff is the same but I wanna change this to a solid disc. All right, you'll see what we just did here when this finishes compiling. Boom. And that was a red disc. I don't know, I kinda like the red too. Obviously it's really up to you what color you choose. Cool. All right, and again, these are all, they all get drawn in order. So what I would do is actually put the solid disc underneath the wire disc. So the wire draws over the solid but in order to do that, I need to say handles. What we could do is actually make this really fancy is just increase the opacity to something like seven, five. Same color. Or you could play around with the different colors. So it doesn't have to be white, right? It is red now, it's more solid. Maybe we change it to a green here. We could play around with colors all day. So let's move this on, okay? So we could do just one and one to get like yellow. There we go. Not too bad. All right, so now what we wanna do is build up that slider that allows us to change that distance, okay? So what I'm gonna do is say handles.drock, draw, sorry. We're going to be doing the scale slider basically. So what I wanna do is say target camera, okay? Dot m distance equals a handles.scale slider, okay? All right, so the scale that we want to adjust is this m distance. So this parameter here is the target camera dot m distance cause that's the value that we wanna change, okay? And the position that we want this particular handle to start at, right, is the cam target. So the cam target dot position, all right? So the target of the camera, okay? The direction was gonna be the cam target dot forward but negative. So I wanted to kind of out the back of the target. Rotation, we don't want any rotation. So I'm just gonna do a quaternion dot identity. All right, it's basically zero. And then the size is going to be that target camera dot m distance value. And then the snap is just gonna be one f, one unit. All right, so let's go see what that looks like. All right, so now we have this slider here that we can actually move and it's gonna change that radius for us. All right, pretty cool. All right, cool. All right, cool. So I wanna change the color of that back to red. So what I'm gonna do is actually use this color again. All right, and now what I wanna do is add a, one of these sliders for the height. So let's do that. And also, actually let's do that first and then I'm gonna talk about a little bit of a bug that you might encounter here. So we wanna do the m height instead. So m height. All right, so I'm just gonna copy that and put that in place for all the values there. All right, and I'm gonna change this one to blue. So this is gonna be zero in red and one in blue. Oh, and we need to do vector three dot up for the direction. So vector three dot up. Cause I want it to represent the height. There we go. So now we have our height. And it might need a little bit more opacity for these guys. So let's do a 0.5 for these handles. It's cool that they have some transparency, but I wanna let the user be able to see these a little bit more. Cool. All right, so that'll adjust the height values of this thing. Perfect. Okay, let's save. And so the thing that could happen, right? A user could be using this and changing something like the distance. And you notice that we're starting to pop. It's because we're getting negative numbers. So I wanna actually put a little bit of control on that. And really, it's good practice to do that. So I'm gonna say target camera dot m distance. And we're going to clamp it actually. So m distance is equal to a math f dot clamp. And it's gonna be target camera dot m distance, right? And we wanna clamp this between something like five f and float dot max value. Not float. Float dot max value. All right, so max value. And that's a big number. So you'll never actually, the user will never get there. But the main thing here is I wanna make sure we don't go negative, right? So that's what that's doing. And that basically takes care of that little bug. All right, so it's kind of a user interface or user workflow type of thing. You wanna make the tools easy. So I actually want it to be a little bit bigger here. The last thing you want is your editor tools to throw off the user, the end user. Then they just think it's broken when it, it's probably not broken per se. It's just when it starts acting wonky like that, everyone comes running to you saying like, oh my God, the tool's broken. You know, there we go. All right, so let's do the same for the height. So I'm just gonna copy this. All right, so we're gonna copy this because I don't need to type all this stuff over again. All right, so there we go. Perfect, so now we have an editor. Editor tool that allows you to edit this stuff. Like I said, in another video, I will talk about serializing the values at runtime, right? So as you're changing this stuff, it's actually saving, but it requires that we get into some scriptable object stuff and I really wanna save that for a different video so I can pull all these guys down now. It allows me to adjust this in the scene. And then you can just come over here and copy the component if you want. Then repaste it once you come out of play mode. All right, so the last thing I wanna do is just kinda spruce this up a little bit. So let's actually add some labels because there's some more stuff I wanna show here before I leave, okay? So I wanna actually make some labels here. So let's do some labels. Create labels and let me be a good programmer and I'm gonna give myself some notes. Slider handles to adjust camera properties. All right, draw distance circle or disk, how about that? Keep it consistent and make sure we have a target first. There we go. Okay, I know it's boring to watch, but it's good practice, good practice. All right, so let's make some labels. So I'm gonna say handles dot labels label and we're gonna put this out of position. So this position is going to be for the distance because I wanna put a little label over the scale slider for the distance property. That way like when someone moves it, they can see that, oh, this is for distance, you know, just helps again. So the position is going to be the cam target dot position plus the negative cam target dot forward dot forward times the target cam dot m distance. All right, and the label is going to be distance. Like so, cool, boom, all right. So we don't need to do that, there we go. Now we have a little label over it. Now it's cool and all, but it's actually got, I don't really like the white that it's set to. So we're gonna have to style that a little bit too. So I'm gonna show you guys how to style these, but let's get the handle or the label for the height set up. So let's do that. All right, so we're gonna say handles dot label plus vector three dot up, right? Cause we want this to be for the height and we're gonna call this the height. So we're gonna use the height here and we'll just say height, cool, cool. Now we have two labels. So it just helps out the end user, right? So now they know what they're editing from here, okay? Let's actually style these things. So you'll notice that there's a couple overrides for, or yeah, overrides for these guys. One of them takes a GUI style here. So let's actually make a new GUI style and style our actual text, right? So I'm gonna say GUI style equal, label style equals a new GUI style, boom. And we're gonna say label style dot font size, sorry, is equal to something like 15F. I'm gonna say label style dot normal dot text color is equal to color dot white. And then I wanna center up the text too. So I'm gonna say dot alignment is equal to text anchor, text anchor, there we go. Middle center, maybe we'll do upper center. How about that? Give us a little room. And then we just need to provide that label style to our label, dope. 15 can't be converted to an int, oh, sorry. There we go, much better. And you can always color them whenever you want again. So then when we go to, we can just pass this label style into this next one, totally. Unless you wanted to change any of these properties. But we should do that just so we can see how you can do that. There we go. But maybe I want the height to be off to the right a little bit. So that's what I was saying. Let's say label style dot alignment now is equal to that text anchor middle right. Like so. So that'll move it over a little bit. You know, again, just comes down to your personal preferences or whatever works well for you or your team, you know. And there we go. That basically is that. And we have this all set up. You can see that we now have a way to select it. And when we select it, we get our editor tool. So we don't have to come all the way over here, not that that's hard. It just makes it easier, you know what I mean? So that is our editor tool. Pretty cool. And it's not too much. I like making these things. It's really fun. All right, so I'll leave you guys there. And in the next video, I just want to wrap up this series and talk about making this a little bit more reusable and how to make a base class that we can use for all of our cameras. All right, thanks so much.