Skip to content

Your first prefab

This tutorial builds one GameObject from components, saves it as a prefab, and spawns copies of it.

  1. Open your tutorial scene if it is not already loaded.
  2. In the Scene Hierarchy, create a new empty GameObject.
  3. Rename it sphere.

New GameObjects come with a Transform. That is enough to start.

  1. Select sphere in the Scene Hierarchy.
  2. In the inspector, Add Component -> Mesh Filter.
  3. Set Kind to Sphere.
  4. Add Component -> Mesh Renderer so it draws.

You should see a sphere in the viewport. Move it beside your cube with the translate gizmo (W), and set Position Y so it sits on the ground.

Ball Prefab
  1. With sphere still selected, Add Component -> Sphere Body.
  2. Open the body component in the inspector.
  3. Leave Motion on Static for now. The physics tutorial switches it to Dynamic.
  1. With sphere still selected, File -> Save prefab (or the Prefab section in the inspector).
  2. Save it under the project’s assets/prefabs/ folder with a name such as sphere.

The prefab is a JSON document under assets/prefabs/. Mesh, renderer, and physics travel with it.

  1. Open the Asset Browser (Shift+Space) if it is closed.
  2. Find the sphere prefab and drag it into the viewport.
  3. Move the new instance so it is not sitting on top of the first one.

You now have two spheres from one prefab. Each instance in the scene is its own copy. Editing one does not change the other.

Prefabs do not auto-update. Saving the prefab file again does not refresh instances already in the scene. They keep what they had until you respawn them from the Asset Browser.

File -> Save Scene (Ctrl+S) so the new GameObjects stay in your scene.

Previous: Your first scene: save a small .scene.

Next: Add physics: a dynamic body and a push.