Pages

Sunday, July 31, 2011

How To use Prefabs in Unity3d

Prefabs

A Prefab is a type of asset -- a reusable Game Object stored in Project View. Prefabs can be inserted into any number of scenes, multiple times per scene. When you add a Prefab to a scene, you create an instance of it. All Prefab instances are linked to the original Prefab and are essentially clones of it. No matter how many instances exist in your project, when you make any changes to the Prefab you will see the change applied to all instances.
How To Add New Prefab .?
Steps:
A new, empty Prefab. It cannot be instanced until you fill it with a GameObject.
To fill the Prefab, you use a GameObject that you've created in the scene.
  1. Choose Assets->Create->Prefab from the menu bar and name your new Prefab.
  2. In Hierarchy View, select the GameObject you wish to make into a Prefab.
  3. Drag & drop the GameObject from the Hierarchy onto the new Prefab in Project View.
After you have performed these steps, the GameObject and all its children have been 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.
To Modify Prefab :
  • Reconnect will discard all differences from the source Prefab.
  • Apply will copy all differences into the source Prefab (and therefore, all other Prefab instances)

Imported Prefabs Looks like :



Video on Prefab : 

















--
Vivek P shah
Game developer in Unity3d
Reference : WWW.unity3d.com

3 comments:

  1. thanks dude
    now that is really easy to use.

    ReplyDelete
  2. Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck!

    ReplyDelete
  3. I am fulfilled to find this post very useful for me, as it contains lot of information. I always want to research the amazing content and this factor I found in you post.

    ReplyDelete