Today is an exciting day because I am introducing a new initiative called “Feature Fridays!” Every Friday you can expect an article from me where I do a deep dive into a particular feature of the Unity game engine. Also I will be featuring a video game, tutorial, or asset pack made with Unity that I find particularly interesting.
This is going to be a great way to dive a little deeper into some features of the Unity game engine so you can work with these tools and build games much more effectively. Also it will be fun to see some of the great things other people are making with Unity that will surely strike inspiration for your projects.
So for the inaugural edition of Feature Fridays, I wanted to talk about something you deal with every time you use the Unity game engine – the Inspector window. Today I’ll be going over:
- The Basics of the Inspector Window
- More Interesting Features of the Inspector Window
- Inspector Features for Power Users
Because of how frequently the Inspector window is used, it’s a good idea to learn about all its powerful features that will save you time when developing.
And don’t forget to read to the bottom so you don’t miss my featured tutorial video of the week – this one comes from the great YouTube channel, Infallible Code!
1. The Basics of The Inspector Window
The Inspector window is the thing that you are likely interacting with the most when you are making games in Unity and it usually looks something like this:
The Inspector window provides the ability for us to add, remove, and modify the components on the GameObject we have selected.
You will also use the Inspector window to change the properties of assets and certain settings within Unity, but today we’ll mainly be talking about using the Inspector window with GameObjects.
By selecting a GameObject in the project Hierarchy, Scene View, or Project Files, the associated components and values specific to that object will be displayed in the Inspector window.
Tip: If at any time you lose the Inspector window, you can open up a new one by going to Window > General > Inspector
Once your Inspector window is populated, feel free to edit any of the values to your heart’s content. Some are represented as sliders or drop-downs and others accept numerical or string values. For numerical fields, if you hover the name of a value, you’ll see a little side-to-side arrow icon; clicking and dragging right and left will increase and decrease the value respectively.
If your Inspector window is getting a bit too cluttered, you can minimize certain components you no longer need to worry about by clicking the drop-down arrow on the upper left of each component. You can also drag components up and down to rearrange them as you see fit.
With the inspector, you can edit multiple things at one time. By selecting multiple objects with Ctrl + Click or Shift + Click, all the components each of the objects have in common will be displayed. This is useful when you want to set the same value for many components at once.
Now what if you want to set the value of a variable for multiple GameObjects to match that of a single one? There actually is an easy way to do that if you already have all the objects you want selected (including the one you are taking the value from). All you need to do is right click on that value, then you are given options to set that value to the value on a specific GameObject. It’s a bit difficult to explain, but give it a shot for yourself and you’ll see how useful it can be.
2. More Interesting Features of the Inspector Window
Now you may have already known about most of those features of the Inspector window as you likely interact with them every time you open Unity. Here are a few lesser known features to try out in the Inspector if you are feeling a bit adventurous.
The Inspector lock is a small icon in the upper right of the Inspector window and it shows as unlocked by default. Clicking on that will “lock” the Inspector. With the Inspector locked, the currently selected object will have their values remain in the Inspector regardless of which object you have selected. The object will stay in the Inspector until you deselect it by clicking on the lock icon again.
The Debug Inspector will give you even more information about the current state of the object that is displaying. To enable it, just click the three vertical dots icon right next to the lock icon in the upper left of the Inspector window, and select “Debug.” This will give you more information about all the components on your object – it will even display the current value of private variables!
One Inspector window is great, but you can actually have as many open as you like. You could, for example, lock the inspector of an object you edit frequently so you can make changes to that whenever you have to, without needing to select the object every time. Another thing that I like to do, is to have two Inspector windows docked on my screen, one normal and one debug, so I can easily tab back and forth between the two.
If you have many Inspector windows open, and you want to locate an object associated with a specific Inspector window in your Scene Hierarchy, just click the same triple dot icon in the upper right, and select “Ping.” This will highlight the object you are looking for right away.
Adding custom icons to an Inspector window is also a very powerful feature. If you click on the icon of a GameObject (located in the upper left, by default it looks like a wire cube) you can select the desired icon. Some icons will display the name of the GameObject, others will be just a primitive shape, and by clicking the “other…” button, you can select your own custom icon. These icons are displayed in the Scene view and clicking on them will select that object – this is great for objects that do not have a renderer component.
If you’ve been enjoying these tips so far, feel free to share this with anyone who might find it useful
3. Inspector Features for Power Users
By now you’re probably feeling like a wizard with the Unity Inspector window, but there are actually two more features that will really change how you work.
One of these features is known as the “Focused Inspector” and it allows you to hone in on the values that you care about. The Focused Inspector is only available in Unity versions 2020.1 and above. You can open the Focused Inspector for a GameObject by right clicking on it in the Scene Hierarchy or Project Files and then selecting “Properties…” at the bottom.
Doing that will launch a new Inspector window that can be resized, docked, or even moved to another monitor. It functions similar to a regular Inspector window although there is no “lock” button as that object will always stay in that Focused Inspector window. Also you cannot enter the Debug Inspector in a Focused window.
But the focused inspector can lock in on one specific component that you need to have open. Just click the three vertical dots on the component (not for the whole object) and click “properties…” to open that specific component in it’s own dedicated Focused Inspector window.
If you have multiple of these open, you can use the “Ping” feature on these as well to locate the object, or simply hover over the tab header for the Inspector to see the full path to that file or object.
The last inspector related thing I wanted to introduce you to today is the concept of custom Inspector windows. Custom Inspector windows are a more advanced feature of Unity where you fully control how specific components appear in the Inspector. You can do all sorts of cool things like adding buttons and sliders and hidden custom behaviors.
Now custom Inspector windows could have an entire course of material dedicated to them, but if you do want an idea about how to get started with custom Inspector windows check out this video I made that will introduce you to the concepts of custom Inspectors and show you how to create your first one!
Intro to Custom Inspectors:
Featured Unity Tutorial of the Week
This week’s featured tutorial comes from the Infallible Code YouTube channel and it is all about writing self-documenting code. Self-documenting code is a way of structuring your code and naming things appropriately so it is obvious about what the code is doing without the need of any comments.
Commenting code may seem like a good idea at first, but how often do the comments get updated in relation to the code being updated? By writing self-documenting code, you eliminate the need for comments which leads to much cleaner class files that are easier to understand.
Oh and the video is really funny and has a Halloween theme ??♂️
Writing Self-Documenting Code:
Alright, so that does it for the first edition of Feature Friday. This is still a bit experimental at this point, so I’d really like to hear back from you about what you thought of it – just post a comment on this blog post or join us over on Discord.
Also be sure to let me know what other features you’d like to see me do a deep dive on or if there are any particular Unity games and tutorials that could be featured in one of these.
Anyways I hope you are all staying well, and as always, keep on creating!
-Johnny Thompson
Turbo Makes Games
Recent Comments