Overview
PrefabKit adds prefabs to Unreal Engine 4.27 and 5.8. A prefab is an asset that stores a group of actors together with their properties and their transforms relative to a pivot. A APrefabKitActor placed in a level builds those actors as its attached children. Edit the children of any instance, save them back to the asset, and every other instance in the level is rebuilt.
- Create a prefab from the current selection with one click; a thumbnail is captured automatically.
- Nested prefabs: a prefab can contain other prefab actors.
- Prefab collections: weighted lists of prefabs; each placed actor picks one entry from its own seed.
- Randomizer and Seed Linker actors for re-rolling a whole level or a chosen set of prefabs.
- Blueprint and C++ API to spawn, randomize, re-assign and unlink prefabs at runtime.
- Runtime construction system: ghost cursor, snap points for floors, walls and objects, build and remove tools, a build menu widget and save/load of player-built levels.
Requirements
| Requirement | Details |
| Unreal Engine | 4.27 and 5.8 (verified clean on both) |
| Modules | PrefabKitRuntime (Runtime), PrefabKitEditor (Editor), PrefabKitEditorPostInit (Editor), PrefabKitConstructionRuntime (Runtime), PrefabKitConstructionEditor (Editor) |
| Dependencies | None (engine modules only; no other plugins are enabled) |
| Language | Blueprints and C++ |
| Platforms | No platform restriction in the plugin descriptor. Win64 is the platform built and verified by Alpha XP; other platforms are supported by the code, not verified by Alpha XP. |
Installation
- Install PrefabKit from Fab into your engine, or copy the
PrefabKit folder into your project's Plugins folder.
- For a C++ project, regenerate project files and build the editor target.
- Open the project, enable PrefabKit in Edit > Plugins and restart the editor.
- C++ only: add the modules you use to your
Build.cs, for example PublicDependencyModuleNames.Add("PrefabKitRuntime"); and, for the construction system, "PrefabKitConstructionRuntime".
Verifying the installA PrefabKit button appears in the level editor toolbar, Project Settings > Plugins > PrefabKit exists, and right-clicking selected actors in the viewport shows Create Prefab (from selection).
Quick start
Create and place a prefab (editor)
- In the Content Browser, select the folder where the new asset should go.
- Select a few actors in the level and click PrefabKit > Create Prefab (from selection) in the toolbar (or right-click in the viewport).
- A prefab asset is created and the actors are attached under a new APrefabKitActor.
- Move, add or change child actors, select the prefab actor and press Save Prefab to Asset in the Details panel.
- Drag the prefab asset from the Content Browser into the level to place more instances.
Spawn a prefab at runtime (Blueprint)
- Add a variable of type UPrefabKitAssetInterface (object reference) and set it to a prefab or prefab collection.
- Call Spawn Prefab with a world context, the asset, a transform and a seed.
- Use the returned prefab actor with Randomize Prefab, Set Prefab Asset or Unlink Prefab.
C++
// Build.cs: PublicDependencyModuleNames.Add("PrefabKitRuntime");
#include "Utils/PrefabKitFunctionLibrary.h"
#include "Asset/PrefabKitAsset.h"
#include "Prefab/PrefabKitActor.h"
// In AMyActor: UPROPERTY(EditAnywhere) TSoftObjectPtr<UPrefabKitAssetInterface> PrefabToSpawn;
void AMyActor::SpawnRoom()
{
if (UPrefabKitAssetInterface* Prefab = PrefabToSpawn.LoadSynchronous())
{
APrefabKitActor* Room = UPrefabKitBlueprintLibrary::SpawnPrefab(this, Prefab, GetActorTransform(), /*Seed*/ 1234);
if (Room)
{
FRandomStream Stream(42);
UPrefabKitBlueprintLibrary::RandomizePrefab(Room, Stream); // pick new variations and rebuild
}
}
}
Editor workflow
Toolbar menu and context menus
| Where | Entry | What it does |
| Toolbar > PrefabKit | Create Prefab (from selection) | Creates a prefab asset in the selected Content Browser folder (or /Game) from the selected actors. Actors that already belong to a selected prefab and actors without a root component are skipped. |
| Toolbar > PrefabKit | Link selected Prefab Collection seeds | Lists the APrefabKitSeedLinker actors in the level; picking one adds the selected prefab actors to its Linked Actors. |
| Toolbar > PrefabKit | User Guide | Opens this documentation. |
| Toolbar > PrefabKit > Advanced | Upgrade assets to latest version | Upgrades every prefab asset in the project to the current data version. Make a backup first. |
| Viewport right-click | Create Prefab (from selection) | Same as the toolbar entry. |
| Content Browser right-click on prefabs | Create Prefab Collection | Creates a collection that contains the selected prefabs. |
| Content Browser right-click on prefabs | Recapture Thumbnail | Renders the thumbnail again with the thumbnail camera settings. |
| Content Browser right-click on prefabs | Upgrade to latest version | Shown only for assets saved with an older data version. |
Details panel buttons
| Selected actor | Buttons |
| Prefab Kit Actor using a prefab | Save Prefab to Asset, Save Prefab to New Asset, Load Prefab from Asset, Randomize, Unlink |
| Prefab Kit Actor using a collection | Randomize (new seed), Reload Prefab; the Seed is editable here |
| Prefab Kit Randomizer | Randomize (switches the viewport to Realtime when the build is spread over frames) |
| Prefab Kit Debug Actor | Save Actor Data, Load Actor Data (serialization test helper) |
Selecting inside a prefabClicking an actor that belongs to a prefab selects the outermost prefab actor first; clicking again steps one level down the hierarchy. When a map is opened, outdated prefab actors in it are rebuilt from their assets.
Prefab assets & actors
| Node | Type | Description |
| UPrefabKitAsset | Asset | Prefab asset (shown as "Prefab"). Stores the actors, their properties and relative transforms. Properties: Event Listener, Replicates. |
| UPrefabKitAssetCollection | Asset | Prefab collection (shown as "Prefab Collection"). Prefabs is a list of Prefab Asset + Weight entries; Custom Thumbnail replaces the thumbnail when the asset is saved. |
| UPrefabKitAssetInterface | Class | Common base of both asset types; use it for variables that accept either. |
| APrefabKitActor | Class | Actor that builds a prefab. Its root UPrefabKitComponent holds the Prefab asset reference; Seed chooses the collection entry. |
| APrefabKitReplicableActor | Class | Variant used by Spawn Prefab when the asset's Replicates option is set; it only enables standard actor replication for the prefab actor itself. |
| Load Prefab | Callable | Rebuilds the child actors from the prefab asset. |
| Save Prefab | Callable | Writes the current child actors back into the prefab asset (editor workflow). |
| Is Prefab Outdated | Pure | True when the asset changed since this actor was last built. |
| Get Prefab Asset | Pure | Returns the prefab this actor builds; for a collection, the entry selected by the actor's seed. |
| Randomize Seed | Callable | Draws a new seed from a random stream, optionally for nested prefabs too (does not rebuild). |
| UPrefabKitEventListener | Class | Blueprintable class assigned to a prefab asset's Event Listener. |
| Post Spawn | Event | Called on a new listener instance after the prefab and all its child prefabs have been spawned and initialized. |
Blueprint library
Static nodes in UPrefabKitBlueprintLibrary (category PrefabKit).
| Node | Type | Description |
| Spawn Prefab | Callable | Spawns a prefab actor for a prefab or collection at a transform, applies the seed and builds it. Returns the prefab actor. |
| Randomize Prefab | Callable | Gives the prefab and its nested prefabs new seeds from a random stream and rebuilds them. |
| Unlink Prefab | Callable | Detaches the child actors (they stay in the level) and destroys the prefab actor. |
| Get All Attached Actors | Callable | Returns every actor attached below an actor, recursively. |
| Set Prefab Asset | Callable | Assigns a prefab or collection to a prefab actor and optionally reloads it. |
| Find Top Most Prefab Actor | Callable | Returns the outermost prefab actor that an actor is attached under, or none. |
Randomization
| Node | Type | Description |
| APrefabKitRandomizer | Class | Actor that re-rolls prefabs in its level. Properties: Randomize On Begin Play (off), Seed Offset (0), Max Build Time Per Frame (0.02 s; spreads the rebuild over frames), Fast Sync Build (off), Actors To Randomize (empty = every prefab in the level). |
| Randomize | Callable | Seeds the randomizer, re-rolls the top-level prefabs, applies seed linkers and rebuilds. |
| On Randomization Complete | Event | Broadcast when the rebuild started by Randomize has finished. |
| APrefabKitSeedLinker | Class | Actor whose Linked Actors all receive the seed of the first linked prefab when the randomizer runs. |
Construction system
The construction system lets players place and remove prefabs at runtime. Add a UPrefabKitConstructionComponent to your Player Controller, assign Build Menu UI (for example ConstructionSystem/UI/PKBuildMenu) and Build Menu Data (a UPrefabKitConstructionUIAsset), and place UPrefabKitConstructionSnapComponent components inside the prefabs players can build.
Input mappings
The component binds these legacy input names (add them under Project Settings > Input):
| Name | Kind | Action |
PrefabKitModeToggle | Action | Enter or leave construction mode |
PrefabKitToggleBuildUI | Action | Show or hide the build menu |
PrefabKitModeToolBuild | Action | Switch to the build tool |
PrefabKitModeToolRemove | Action | Switch to the remove tool |
PrefabKitBuildAtCursor | Action | Place the cursor prefab |
PrefabKitCursorItemNext, PrefabKitCursorItemPrev | Action | Cycle collection variations of the cursor prefab |
PrefabKitCursorRotate | Axis | Rotate the cursor prefab in steps |
PrefabKitRemoveAtCursor | Action | Remove the prefab under the cursor |
Collision setupCreate an object collision channel named PrefabSnapChannel and a collision preset named PrefabSnap (query only, overlapping PrefabSnapChannel). Snap components use the PrefabSnap preset; without the channel, traces fall back to WorldStatic and snapping does not work.
Construction component
| Node | Type | Description |
| UPrefabKitConstructionComponent | Class | Player Controller component. Properties: Cursor Material, Cursor Invalid Material, Trace Start Distance (1000), Trace Sweep Radius (40), Construction Camera Actor, Construction Camera Transition Time (0.15), Construction Camera Transition Exp (1.0), Build Menu UI, Build Menu Data. |
| Toggle Construction System | Callable | Enables construction mode with the active tool, or disables it. |
| Enable Construction System | Callable | Blends to the Construction Camera Actor (when one is set) and activates the given tool (Build Tool or Remove Tool). |
| Disable Construction System | Callable | Disables the active tool and blends back to the controlled pawn. |
| Show Build Menu | Callable | Adds the build menu to the viewport, switches to game-and-UI input and pauses tool input. |
| Hide Build Menu | Callable | Removes the build menu and restores game input. |
| Set Active Tool | Callable | Switches between the build and remove tools. |
| Get Active Tool Type | Pure | Returns the active EPrefabKitConstructionToolType. |
| Get Active Tool | Pure | Returns the active tool object. |
| Get Tool | Pure | Returns the tool object for a tool type. |
Tools
| Node | Type | Description |
| UPrefabKitConstructionBuildTool | Class | Shows a ghost of the active prefab at the cursor, snaps it to snap components, tints it with the invalid material when it overlaps existing geometry or exceeds the slope limit. Properties: Trace Distance (4000), Cursor Rotation Step Angle (15). |
| Set Active Prefab | Callable | Sets the prefab or collection the build tool places. |
| UPrefabKitConstructionRemoveTool | Class | Highlights and removes the prefab under the cursor. Property: Trace Distance (4000). |
Snapping
| Node | Type | Description |
| UPrefabKitConstructionSnapComponent | Class | Box component placed in buildable prefabs. Properties: Snap Type (Floor, Wall, Object), Floor Constraint (AttachX/AttachY/AttachZ and their negative sides), Wall Constraint (AttachTop, AttachBottom, AttachLeft, AttachRight), Align To Ground Slope, Use Max Ground Slope Constraint, Max Ground Placement Slope (60). |
| APrefabKitConstructionSnap | Class | Actor wrapper around a snap component, for placing snap points directly in a prefab. |
Build menu
| Node | Type | Description |
| UPrefabKitConstructionUIAsset | Asset | Data asset for the build menu: Menu Title and Categories (Display Name, Icon, Prefab Entries with Display Name, Tooltip, Icon, Prefab). |
| UPrefabKitConstructionBuildUI | Class | Interface the build menu widget must implement. |
| Set UI Asset | Event | Receives the Build Menu Data asset when the menu is created. |
| Set Construction System | Event | Receives the construction component that owns the menu. |
Saving player-built levels
| Node | Type | Description |
| Save Construction System Level | Callable | Saves every prefab placed by the construction system (asset, seed, transform) and optionally the player's transform and control rotation to a save slot. |
| Load Construction System Level | Callable | Opens a level and passes the save slot and user index as level options (PrefabKitSlot, PrefabKitUserId). |
| Handle Construction System Level Load | Callable | Call after the level has loaded (on the server); reads those options, rebuilds the saved prefabs and restores the player. |
| UPrefabKitConstructionSaveGame | Class | Save game object used by the nodes above. |
Settings
Project Settings > Plugins > PrefabKit (stored in DefaultPrefabKit.ini).
| Setting | Default | Description |
| Pivot Position | Center | Where the pivot of a new prefab is placed: Center, Extreme Left or Extreme Right of the selection bounds (always on the bottom of the bounds). |
| Allow Dynamic Update | On | When a prefab is saved, rebuild the other instances of it in the level. |
| Ignore Bounding Box For Objects | Draw Frustum Component | Classes ignored when prefab bounds are computed (restart required). |
| Default Thumbnail Pitch | -11.25 | Thumbnail camera pitch for new prefab assets. |
| Default Thumbnail Yaw | -157.5 | Thumbnail camera yaw for new prefab assets. |
| Default Thumbnail Zoom | 0 | Thumbnail camera zoom offset for new prefab assets. |
Content
| Asset | Type | Purpose |
ConstructionSystem/UI/PKBuildMenu | Asset | Widget Blueprint: ready-made build menu that implements the build UI interface and lists the categories and prefabs of the Build Menu Data asset. |
ConstructionSystem/UI/Support/PKBuildMenu_CategoryInfo, PKBuildMenu_PrefabInfo | Asset | Blueprint list-item objects used by the build menu. |
ConstructionSystem/UI/Support/PKBuildMenu_CategoryItemUI, PKBuildMenu_PrefabItemUI | Asset | Widget Blueprints for one category / one prefab entry in the menu. |
ConstructionSystem/UI/Textures/LevelBounds_64x, ObjectLibrary_64x | Asset | Default menu icons. |
PrefabTool/Materials/M_PKCursor, M_PKCursor_Inst, M_PKCursor_InvalidLocation | Asset | Ghost cursor material and its valid / invalid placement instances (use them for Cursor Material and Cursor Invalid Material). |
PrefabTool/Sprites/Icon_48, Icon_48_linker, Icon_48_randomizer | Asset | Editor sprites for prefab, seed linker and randomizer actors. |
PrefabTool/Icons/*.png | Image files | Editor toolbar and class icons loaded by the plugin's style set. |
Troubleshooting
| Symptom | Cause and fix |
| Create Prefab is disabled or creates nothing | At least one actor must be selected. Actors without a root component, and actors that already belong to a selected prefab, are skipped. |
| Other instances do not change after Save Prefab to Asset | Allow Dynamic Update is off in the project settings. Turn it on, or press Load Prefab from Asset on each instance. |
| An asset is labelled "Prefab (upgrade required, right click)" | It was saved with an older data version. Right-click it and choose Upgrade to latest version, or use PrefabKit > Advanced > Upgrade assets to latest version. |
| The randomizer appears to stop half way in the editor | With Max Build Time Per Frame above 0 the rebuild runs over several frames; the editor switches the viewport to Realtime so it can finish. Set Max Build Time Per Frame to 0 to rebuild everything in one frame. |
| Construction input does nothing | The component must be on the Player Controller and the input names listed above must exist in the project's input settings. |
| The ghost cursor never snaps | The PrefabSnapChannel object channel or the PrefabSnap preset is missing, or the prefab has no UPrefabKitConstructionSnapComponent. |
| The build menu never appears | Both Build Menu UI and Build Menu Data must be set; the widget must implement the build UI interface (an error is logged otherwise). |
| Spawn Prefab returns nothing | The world context did not resolve to a world, or no prefab asset was passed. Pass self from an actor and a valid prefab or collection. |