From the course: Unity 3D 2019 Essential Training

What are prefabs? - Unity Tutorial

From the course: Unity 3D 2019 Essential Training

Start my 1-month free trial

What are prefabs?

- [Instructor] If you've read or watched anything related to Unity, you may have heard of this term, prefabs. A prefab, in its simplest form, are templates from which you can create multiple instances of the same object, keeping all its properties. And when you need to make a change to the instances, you simply update the prefab and all its children will be updated. Typically, prefabs are used for props or NPCs which is short for non-player character. So for example, if you want to create a forest with dozens of similar trees, prefabs are perfect for this. You can create a player prefab if you'd like to but since a game typically only has a single character instance, this might not be useful. You can also nest prefabs and create variations within these nested branches of your hierarchy. For example, if you wanted to create two different sets of trees with dozens of children each but one's set with green leaves and the other one with blue leaves, you could do it. In other words, you can override nested branches of your prefabs and then create variations for those branches so your forest isn't made only of one type of tree but many variations. What you don't realize is that we already created one without knowing. When we imported the house model into our project folder, we created a prefab and you can tell it is a prefab by looking at the hierarchy where the house portion has a blue icon, therefore, it's a prefab. We'll explore all these different aspects of prefabs in this chapter.

Contents