 Howdy guys in the pixel here, and what I wanted to do in this next series of editor tools videos I is I want to actually build a tool that helps me group objects So I know if you've been building stuff in unity for a while It's kind of you know tough basically There isn't any functionality that I know of at least that allows me to go and just group two objects together And honestly, I do this quite often to organize my scenes. Okay, so One thing I want to do is I want to be able to select two objects and then just hit some sort of hot key Combination and what it'll do is it'll create an empty game object called boxes group or something like that, right? And it'll automatically just parent these guys underneath like so Okay, so I know it's not like, you know super crazy Technical tool or anything like that But what I'm really trying to do is just focus on all these little tiny tools and just get us used to making editor tools And you know throughout this whole series, which is just going to be ongoing We're just going to start making more complex and more complex tools and maybe get into some more Aesthetics of the editor tools and how you modify the look of all your tools and stuff like that. So We're just going to take some baby steps first. All right, so To get things started for this particular tool What I want to do is I want to go down into my Tools that we've been building and create a new folder and this one's going to be called the object group or tool Like so Or it could be called group objects. I'm kind of trying to stick to a naming convention here It'll obviously have to change at some point because we're not going to be doing Stuff with objects all the time Like 3d objects. I mean so inside of that we need to create that editor's folder All right, so that is required to have any editor tool actually work inside of Unity you need to we'll look into this specific folder here and Automatically say okay, this is going to be an editor type of tool or I'm going to Look at this like an editor script Okay, so then what we want to do or at least the first thing that I like to do is create a menu script So I'm going to say IP for any pixel. This is going to be object Grouper menu. All right, and the reason why I do this is because I basically want to wait. I basically want to Create a menu for this so that we can actually access the tool So if you've been watching the previous videos in this series We do this for every tool that we write and we also attach a hotkey to it So we'll cover how to do all that stuff if this is the first Video you are watching in the series Okay, so we need to add it to this menu and we do that with the script And I like to do this because it separates my code From the actual editor code. All right, so I'm going to put this into a namespace called Indie pixel and We're going to put it into tools All right, and now by putting it in that namespace It allows us to protect our code from other people's classes that might have the same class name All right, this just prevents naming convention clashes all right, so the next thing I want to do is Declare a public so this is the object replace Tool here. We want to declare this public static void Method with a menu item and in order to do that what we need to do is we need to Say that we're using the Unity editor namespace and the reason for that is because menu item this particular attribute right here this method attribute is Contained within that namespace so if we don't declare this we can't actually see that all right So now that we have that namespace in place We can say a menu item and we can give this a path now the path I've been using is Indie pixel level tools in this case and then whatever the name of the tool is all right so In your case you might want to you know add your own so maybe your own name or your project name or whatever You know branding name that you have all right You can add whatever you want and this is going to be the object grouper All right, so We'll get in the hockey here in just a second So at this point now I want to declare a public static void and we're going to call this launch object grouper All right because this method is going to be the method That gets fired off Right when we click this particular menu item All right, so to test that let's just do this here really can't go do a debug log and we'll say launching object grouper I always got to put the exclamation mark in there because this means I'm serious serious business All right so I'm going to let that compile and We're going to go to Indie pixel now and we'll go to level tools and there we go We have our object grouper and if I click this you can see in the console It says launching object grouper, so we are working so we're firing off that method and any logic that's contained within that method okay, so let's go and Get the editor script up and rolling Okay, so these little mini tools as I like to call them usually have this kind of format or at least when I'm developing them I create a manuscript and then an editor script. Okay, so let's go and actually Create The editor script for this and this is going to contain the code that actually displays the window and all the UI I didn't want to create a folder all the UI that Is for the tool itself. This will allow us to input like a group name Or other features, so it's add a new C sharp script. We're gonna say IP object grouper We'll say editor All right We'll say yeah, and it keeps launching visual studio when I do that so weird Literally just started happening today. Okay, so again, we're gonna put this into the namespace Okay, so whatever namespace you're using and honestly, you don't have to use a namespace I just like doing that because it is clean. It's a good practice to get into And it protects your code so What i'm going to do now is add a C sharp region and these are useful just to organize your code So these are going to be all my variables that we have if we have any We will actually so and then we'll do the built-in methods all right Like so And then we'll do our custom methods like so All right Okay, so in order for this to actually display a window inside of unity an editor window Okay, what we need to do is we definitely need to be using the unity editor namespace because that contains all that All the classes all the code that is required to draw something inside of unity And then we have to make this particular class inherit not from mono behavior, but from an editor window All right, so that's how we get an editor window to pop open And again, this is a lot of review if you've been watching the The series so far just want to make sure I save this here Okay, and now what we do in terms of Launching the actual editor windows we come in here and we create a public static void we'll call this launch grouper window or something like that. You can call it whatever you want really Like so and let's just do a debug log here just to get the point across so we're going to say launching editor Okay, so now if I go back to my object grouper menu over here, okay, and we come in here and we say ip object grouper editor dot launch grouper window And the reason why we can do that is because we made the method over here static All right, so this basically there's just one instance of this particular method and you can automatically see it In the script itself without having to like instantiate the script or anything like that And store it in memory. So this allows us to actually see that menu which then If we have done everything correct, we'll display this in the console. Okay All right, I'm going to come up here and we'll say object grouper and boom. We have launching editor. Perfect Okay, so with that we are pretty much good to go I'm going to close the video out there in the next video We're going to go and get the window actually drawing inside of the editor. Okay. Thanks so much