Join Kelley Hecker for an in-depth discussion in this video Introducing Component and MonoBehaviour, part of Scripting Unity with C#.
- You might have noticed that the script we made…in the last chapter extended from MonoBehaviour.…With few exceptions,…like scriptable objects and editor scripts,…which we won't cover in this course,…every script you write will extend from MonoBehaviour.…Unity is very component-based.…When you combined a stinch of reusable components…to achieve your desired functionality.…In Unity, a component is anything you attach…to a GameObject, such as lights, colliders,…renderers and scripts.…So what is a MonoBehaviour?…A MonoBehaviour is any script…that can be attached a GameObject.…
If your script doesn't extend from MonoBehaviour,…you won't be able to attach it to an object in your scene.…So all script components are MonoBehaviours.…The MonoBehaviour class also includes…many useful functions and events.…
- 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.