lesson 15: Inspector View
In lesson 15 we'll inspect the Inspector View. We'll review its primary and secondary purposes. In study of its primary function, we'll delve into Component elements as well.
Fig. 15.1 shows the Inspector View.
As demonstrated previously, the Inspector View is contextual. What it displays will vary with what is selected. The Inspector View allows us insight and access to everything from assets to editor settings, but is used primarily to inspect and edit GameObject Components. With a GameObject selected, newly created Components appear in the Inspector View.
Fig. 15.2 shows the Inspector View GameObject Header.
When any GameObject is selected, the Inspector View will display a GameObject Header. Left most is a cube with an arrow. Arrows of this type are used to denote that an editor element can be alternately expanded and collapsed. Clicking the cube elicits an icon menu. Here you can assign the GameObject additional visual information, such as an icon and custom color, which will appear in Scene View. Clicking the cube a second time dismisses the menu. Next to the cube is the Activation Checkbox. It is used to activate and deactivate the selected GameObject. It doesn't simply make the GameObject invisible; that would be accomplished by deactivating a Mesh Renderer Component. It doesn't destroy the GameObject; the engine can reactivate it when necessary. Deactivating a GameObject simply lets it rest inactive until such time that it requires processing resources. After the Activation Checkbox is a text input field with the GameObject's name. You can rename the GameObject here. Next is the Static Checkbox. Check it to inform the engine that the GameObject is not meant to move and that it needn't ever concern itself with moving it. Next to the Static Checkbox is access to a drop-down menu. Here you can select from other processes that you can inform the engine to ignore with respect to the selected GameObject. This is part of an optimization process. There are a minimum of optimization techniques that even non-programming game developers should be aware of; Object Pooling, Static Batching and its modern equivalents, and Lightmapping (aka, baking). Tags and Layers were discussed in a previous lesson. Here in the GameObject's Inspector Header you can add and/or assign Tags and Layers. If the GameObject is a Prefab an additional Prefab row will appear containing the options to Select, Revert, and Apply. These functions were covered in lesson 4.1.
Fig. 15.3 shows the Main Camera's Component elements.
The Inspector View allows developers to easily specify and edit a GameObject's functionality. This is done through scripts attached as Components. The first Component, and the one Component shared by all GameObjects, is the Transform Component. In the upper left-hand corner of the Component element is an arrow that can be used to collapse the Component. This saves on Inspector View real-estate. With it expanded, editable variables and parameters are exposed should there be any. In the example of the Transform Component, these parameters are Position, Rotation, and Scale values. They can be edited here and the effects can be seen (where else?) in the Scene View. Because the Transform Component is a prerequisite for being a GameObject, it lacks an Activation Checkbox. Other Components can be activated and deactivated which is useful when tweaking and troubleshooting. To the right of the Component's name, which is determined by the script, is a book with a question mark. This signifies Help. Clicking it will open up to the Component's documentation in the offline Unity Manual. The next icon, a pair of sliders, is the Select Preset tool and allows you to select any presets for the Component, should they exist. It also allows you to save the Component's current configuration as a preset that you can reuse. The Gear icon expands the Component Context Menu. This allows access to options such as Reset, Revert to Prefab, Remove Component, Copy/Paste Component and Component Values, Move Up/down.
The heart of the Inspector View is the Component, and here Components allow easy access to script variables and parameters. Values and settings can be inputted in text fields, dialed in using sliders, and selected from drop-downs.
Assets, such as materials and textures, can likewise be selected. Assets are typically chosen in a window that's been launched by clicking a target icon. Options, even the Component itself, can be toggled on and off using checkboxes. There are many ways to edit the endless expanse of Component features, most of which are typical to the visual language of software editing programs.
At the very bottom of a GameObject's Inspector View is the Add Component button. Here you can select Components by navigating the type hierarchy or by searching, as we've done previously. You can also chose to create a New Script where you'll be asked to name it and select a programming language. After creating it, double-clicking it in the Project View will launch it in MonoDevelop, Unity's companion programming application. Of course, we won't be creating scripts, we'll be creating PlayMaker FSMs. These too attach to a GameObject as a Component in much the same way that scripts do.
In this lesson we learned that the Inspector View allows us insight and access to everything from assets to editor settings, but is used primarily to inspect and edit GameObject Components. It is where GameObject meets Component, where art meets code. Here GameObjects are given their functionality and that functionality can be further tweaked by editing the variables and parameters made available in the Component. Next, our last View, Console View!