Unity3d creating a prefab

unity3d create a prefab

There is a usable feature in Unity3d called prefabs. Prefabs allow you to encapsulate and then re-use pieces of in-game graphics.

When you need to have more than one similar objects in game there’s 2 ways of doing it in Unity:

  1. Create a single object. Set it up. Copy-paste it to any place you need it.
  2. Create a single object. Set it up. Create a prefab from it. Re-use it in any place.

Both ways are very simple, but the first one is not a good option for game development. Why? Imagine that you copy-pasted a hundred of enemies in your game scene. Then recently you need to chage something (for example, the size) in your object. And now there’s no options left for you except manually changing the size for every object in the hundred.

Prefab is a game object saved as a file in the Project tab of the Unity editor. To create a prefab simply drag an object from scene to some directory in Project tab.

Prefabs benefits

The main benefit of using prefabs is a possibily to change settings of all created objects while changing the prefab object only.

Once you edited a prefab, all objects will inherit changes and you will not need to change then manually one by one.

Leave a Reply

Be the First to Comment!