Prefabs
Build an object once, then place copies.
A prefab is an object, including its children, saved as a file. Each copy in a scene stays linked to that file. Edit the file, press Apply, and the copies update.
1. Build the object
Make it in the Hierarchy the way you want every copy to start: the sprite, the animator, the children. Name it. The file will use that name.
2. Create the prefab
- Right-click the object in the Hierarchy.
- Choose Create Prefab.
The editor writes Prefabs/Name.wpb. The object you clicked stays in the scene, and it is now a copy of that prefab. Select it and the Inspector names the prefab at the top.
3. Place another copy
- Find the
.wpbin the Project panel, under Prefabs. - Drag it onto empty space in the Hierarchy. A copy is placed in the active scene.
- Drag it onto an object when the copy should be a child of that object.
Move each copy where it belongs. A copy keeps its own position.
4. Edit the prefab itself
- Double-click the
.wpbin the Project panel. You can also right-click a copy and choose Open Prefab, or press Open on the prefab line in the Inspector. - The scenes step aside. The Hierarchy shows only the prefab, with < Back and Apply at the top.
- Change the object. Add a child, swap the sprite, or change a component.
- Press Apply. That writes the
.wpband updates the copies in the open scenes. Ctrl+S does the same while you are editing the prefab.
Each copy keeps its name, whether it is on, and its position. Anything else you had changed on a copy is replaced by the prefab.
Press < Back to return to the scenes. If Apply has not been pressed, you are asked before those edits are dropped.
5. Change one copy
Select the copy in the scene. The Inspector shows the prefab line and four buttons:
- Open — edit the prefab itself, the same as Open Prefab.
- Apply — write this copy over the prefab file.
- Revert — put this copy back to what the file says.
- Disassemble — turn this copy into ordinary objects. It is no longer linked.
The same commands are on the right-click menu: Apply to Prefab, Revert to Prefab, and Disassemble Prefab.
Save the scene after you place or move copies. The prefab file is already written when you create it or press Apply.
Leave with < Back before you build. A build will not start while the prefab is still open.
The reference for scripts, collision, UI, and builds is the documentation.