Book Image

Building Levels in Unity

By : Volodymyr Gerasimov
Book Image

Building Levels in Unity

By: Volodymyr Gerasimov

Overview of this book

Table of Contents (17 chapters)
Building Levels in Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Dealing with Basic Animations
Index

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 a prefab that this object belongs to in the Project window.

  • Revert will reset all changes done to the object and make it identical to the prefab.

  • Apply will update the prefab with changes done to the object.

Try creating more instances of the prefab...