Join Kelley Hecker for an in-depth discussion in this video Using the Inspector, part of Scripting Unity with C#.
- The Inspector, over here on the right,…allows you quick access to the variables…defined in your script.…Click on an object in the hierarchy…to see all the scripts attached to it.…What you see in the Inspector…will depend on the variable type.…For an int, we see a text box that only accepts…number input.…If we change this to a string…we now get a text box that accepts alpha-numeric input.…
If the variable is a boolean,…we see a check box, representing true and false.…A GameObject variable shows a box…where we can drag a reference…to another GameObject from our scene.…Even if we have the same script attached…to multiple GameObjects,…they can each have different values…defined in the Inspector.…
You can even modify these values while the game is running.…Just remember to write down the values…if you change anything because once you stop the game…the Inspector values will revert to that they were…before you hit play.…By default, only public variables appear in the Inspector.…If you want to display a private variable,…
- Defining classes and variables
- Attaching scripts to objects
- Understanding MonoBehaviour class
- Using the Unity Scripting API
- Importing assets
- Using a singleton pattern to manage game state
- Creating an event
Skill Level Intermediate
Q: Why am I getting a script compile error when trying to load the exercise files?
A: This course was recorded in Unity 4.6, and Unity has since released Unity 5. There are two items to address for Unity 5 users.
Q: Why can't I see the Render Settings option in the Edit menu?
A: The Render Settings options have been moved in Unity 5. You can access them by going to the Window menu and choosing Lighting. In the window that loads, Render Settings can be found under the Scene tab.