Part 02 - Concepts.
These are the basic unit of object. They are almost abstract in definition and are the fundamental thing that hold all other things.
GameObject is made up of many components
These are the things that define what a
GameObject does. Everything that an object does is a
Component, in essence. From the way it works, how it looks, how it interacts with other objects, if it makes a noise. Every little details of an object is defined in a Component.
If you need an object to react to a click, you'd define a
Script as a
Component and attach it to a
If an object renders to the screen (i.e. a
Camera) you'd create the code required to do the rendering in a script and attach as a
Component to a
The mechanics of a game are defined as scripts and attached, in the scene, as
GameObjects, even if they have no direct impact on the rendering, the audio or any other direct part of the scene, they need to be in the scene to do anything.
GameObjects can be referenced in
Components, either as
GameObjects, or as references to the types of
Components they contain. So, for instance you can refer to a
Text component of an
Input text area, instead of the whole game object, and refer to it's exposed functionality, instead of the abstract
Serializable fields of a Component are automatically exposed in the editor and can be updated directly in the GUI. They will default to the default value, or the value they are set in the class, but they won't update their default value once it has been created. Something to be aware of when changing code.
Prefab are a kind of
GameObject template. They are
GameObjects that have had their definition saved out as a file and can be instantiated into the scene as a copy. Instead of being part of the scene, they are part of the project folder structure, in the assets folder. You can attach them as references, in a
Component, like any other
GameObject, instantiate them, and then they will be fully usable objects in the scene, as they they were there all along. They can also be added to the scene at design time also, and all the references to the
Prefab to share common values for attributes, or allow them to be overridden and become slightly detached. So a
Prefab may have a different colour for instance.
Another type of special object is called a
This is designed to be an object that contains data.
It's made to be saved into the project and can be passed around as data and used to populate other objects as a lightweight
GameObject that has none of the overheads of needing processing like they do. They are serialized as
GameObjects are and have a few pieces of functionality built in.
The 3d Axes are X,Y,Z. Positive (+ve) X goes to the right, +ve Y up, +ve Z into the screen
More posts in this series.
- Part 04 - Git and Unity
- Part 05 - Building a project
- Part 06 - Adding some plugins
- Part 07 - Creating some objects
- Part 08 - Physics
- Part 09 - Pushing things & animation
- Part 10 - Pushing coins
- Part 11 - Custom Scripting
- Part 12 - Spawning Things
- Part 13 - It is still too fast
- Part 14 - Coins are piling up
- Part 15 - Materials
- Part 16 - User Control
- Part 17 - Keyboard input - Fire
- Part 18 - Keyboard input - Movement
- Part 19 - Deleting Coins
- Part 20 - Walls
- Part 21 - Adding a GUI
- Part 22 - Adding the GameController
- Part 23 - Scoring Links with Events
- Part 24 - Refining the Game - Part 1
- Part 25 - Refining the Game - Part 2
- Part 26 - Refining the Game - Part 3
- Part 27 - More Refinements
- Part 28 - Slowing the user down
- Part 29 - Some more changes