Guides GameObjects What Are Prefabs?

GameObjects 2 min read Updated Apr 2026

What Are Prefabs?

A prefab is a reusable GameObject setup saved as an asset.

Use prefabs when you want to create the same kind of object more than once without rebuilding it by hand each time.

What a Prefab Stores

A prefab can store:

  • a GameObject name
  • a hierarchy of child objects
  • Transform values
  • components
  • component field values
  • asset references

That means a prefab can represent a complete authored object, such as a pickup, projectile, enemy, platform, UI panel, or player helper object.

Prefab Instances

When you place a prefab into a scene, the placed object is a prefab instance.

The Inspector can show the prefab source and whether the instance differs from the saved prefab. Use this to understand whether a scene object still matches the reusable asset it came from.

Prefab workflows help you:

  • update common objects from one source
  • keep repeated objects consistent
  • make scene content faster to author
  • reduce drift between copies

Save a Scene Object as a Prefab

When you have a GameObject set up the way you want, save it as a prefab so it can be reused.

The scene Hierarchy context menu with Save as Prefab highlighted for the selected P1 Paddle GameObject.

In the Hierarchy, right-click the GameObject and choose Save as Prefab....

Use this when an object already exists in the scene and you want to turn that authored setup into a reusable asset.

Create or Instantiate from the Assets Panel

Prefab assets live in the project like other assets.

The Assets panel showing a prefab asset selected, with Instantiate in Scene and Prefab From Selected available in the context menu.

From the Assets panel, you can use prefab actions such as:

  • Instantiate in Scene to place an existing prefab into the current scene
  • Prefab From Selected to create a prefab from the currently selected scene object

Use the Prefabs folder to keep reusable object assets easy to find.

Instantiate from Gameplay

Gameplay code can instantiate prefabs when it needs to create objects at runtime.

<?php

declare(strict_types=1);

namespace MyGame\Game\Scripts;

use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\Prefab;

final class EnemySpawner extends Behaviour
{
    public function spawnEnemy(): void
    {
        $enemy = Prefab::instantiate('Assets/Prefabs/Enemy.prefab.json', 'Enemy');

        if ($enemy === null) {
            return;
        }

        $enemy->transform->position = $this->transform->position;
    }
}

Use prefabs for objects that should be authored once and reused many times.

Keep Prefabs Focused

A good prefab has a clear reason to exist.

For example:

  • Enemy.prefab.json
  • Projectile.prefab.json
  • Coin.prefab.json
  • PauseMenu.prefab.json
  • ImpactFx.prefab.json

Avoid turning one prefab into a giant catch-all object. Smaller prefabs are easier to reuse, test, and replace.

What Comes Next