In Unity, we tend to have one Class per Script, so the terms are often used somewhat interchangeably.
At its core, Unity is built around GameObjects and Components:
GameObject: The fundamental building block in Unity. (e.g. A character, lights, or UI elements.)Component: Defines behavior or characteristics, attached to GameObjects. (e.g. Scripts, transforms, renderers, colliders, animators.)MonoBehaviouris a special type of Component you create by writing scripts.
Key Unity Components
- Transform: controls position, rotation, scale of GameObjects.
transform.position = new Vector3(0, 1, 0); // Move GameObject to (0, 1, 0)- Renderer: determines how GameObjects visually appear. (e.g. MeshRenderer)
- Collider: handles physical interactions. (e.g. collision detection)
- Rigidbody: adds physics-based movement.
- AudioSource: plays sounds attached to GameObjects.
MonoBehaviour is a special type of the base class for all scripts you attach to Unity GameObjects—bridging to Unity’s internal system to add custom behaviour and providing lifecycle methods. Every interactive script you write typically inherits from this class.
- Note: Mono references the underlying Mono runtime of the .NET framework; it has nothing to do with “single” versus “multiple.” All Unity behaviour scripts inherit from MonoBehaviour.
Unity MonoBehavior scripts use built-in lifecycle methods. Here’s a few of them:
| Method | When is it called? | What is it good for? |
|---|---|---|
| Awake() | Called once, when script is loaded. Happens before the scene fully starts, and before Start(). | Ideal for caching references or initial setup (like constructors). |
| Start() | Called once, initialization after all Awake() calls run. At scene start or when the GameObject first becomes active. | Initialization logic that depends on other objects being fully initialized. |
| Update() | Called every frame (~60 times per second). | Continuous game logic. Note: minimize logic since it runs so often. |
| OnDisable() | Object is disabled or deactivated, but may be enabled again later. | Pause gameplay logic, audio, timers, etc. |
| OnDestroy() | Called once, immediately before the object is destroyed permanently. | Cleanup logic, releasing resources. |
You can visualize GameObjects, Components, and MonoBehaviour being composed like so:
GameObject: RobotCompanion
├── Transform (Component) // Position, rotation, scale
├── Renderer (Component) // Appearance (robot model)
├── AudioSource (Component) // Plays voice output
└── YourCustomScript (MonoBehaviour)
├── Awake() // Early initialization
├── Start() // Initial setup
├── Update() // Ongoing per-frame logic
└── OnDestroy() // Cleanup logic