8-Laser Set Up — Concept of Prefab

YShu
Unity2D Game-Galaxy Shooter Dev Log
2 min readMar 30, 2021
  • A game object is first created in the hierarchy to represent the laser projectile.
  • A laser prefab is then created by dragging the game object in the hierarchy into the “Assets->Prefabs”, where a dedicated “Prefabs” folder is created to keep the file structure clean. The symbol next to the Laser object will turn solid blue to indicate that it is a prefab.

The concept of Prefab:

  • It is basically a reusable object.
  • If there are shared instances of the objects (in this case, the Laser game object will be created every time the player hits the space bar), then a Prefab of the object can be created.
  • To modify a Prefab:
    - If the modification is done in the hierarchy, then the changes need to be applied in the Override dropdown menu.
  • Alternatively, we can always open the prefab and make modifications, which will be applied automatically to all the prefabs that have been created in the hierarchy.
  • Now we can create as many Lasers as we want in the game just by dragging the Laser prefab into the scene.

--

--