© Casey Hardman  2020
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-5656-5_5

5. Prefabs

Casey Hardman1 
(1)
West Palm Beach, FL, USA
 

A prefab is a type of asset you’ll store in your project. They act something like a blueprint for objects. You set up a prefab for some kind of object in your game and then add instances of the prefab to your game, in any of your scenes. This connection to the prefab will remain across all the instances, and you can then change the prefab itself to automatically change every instance you’ve placed.

For example, you might make a prefab out of a certain enemy type. You place that kind of enemy throughout your game levels (scenes) possibly hundreds of times. Somewhere down the line, you ...

Get Game Programming with Unity and C#: A Complete Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.