What are Prefabs-
A Prefab is a reusable Game Object stored in Project View . We can have prefabs in number of scenes or multiple times per scene. Adding a prefab in our game is creating an instance of it. All Prefab instances are linked to the original Prefab or we can say are clones of it. When we make any changes to the prefab object , it automatically applied to all its instances.
Steps to add a new prefab-
A new, empty Prefab cannot be instantiated until it contains a game object.
In order to create a Prefab, simply drag a GameObject that we have created in the scene into the Project View. The GameObject's name will turn blue to show that it is a Prefab. We can rename our new Prefab for our readability.
1. Choose Assets->Create->Prefab from the menu bar and name to new Prefab.
2. In Hierarchy View, select the GameObject for which we want to create prefab.
3. Drag & drop the GameObject from the Hierarchy onto the new Prefab in Project View.
After this, the GameObject and all its children are now copied into the Prefab data. The Prefab can now be re-used in multiple instances. The original GameObject in the Hierarchy has now become an instance of the Prefab.
0 Comment(s)