O'Reilly logo

Building Levels in Unity by Volodymyr Gerasimov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Prefabs

Let's say you've configured a GameObject and its components, and you now want to reuse it multiple times throughout the project. Duplication is an option; however, there is a much better way, in the form of prefabs.

Think about prefabs as templates—they are generally used to create instances of certain objects and quickly modify them by applying changes made to the templates.

Creating prefabs is easy:

  1. Click on the Create button of the Project window.
  2. Select Prefab.
  3. Drag and drop a primitive created earlier onto the prefab.

Done! Now you can observe how the prefab works. Notice that our original primitive in the Scene window now gained a new section called Prefab at the top of the Inspector window with three options available:

  • Select will select ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required