class

PrefabInstantiator

Engine-side prefab → entity-tree instantiation. Operates on PrefabAsset (already parsed MDF nodes per entity) so it works in Runtime / dedicated server / any build without the editor.

Module
Game
Header
#include "Scene/PrefabInstantiator.h"
Namespace
Mowo

What's deserialized (scope): Transform, Light, RigidBody, Collider, AudioSource, AnimatorComponent, Camera, ParticleEmitter, ... Limitation: MeshRenderer / Material asset resolution is handled best-effort via AssetManager::TryGet() — works for assets present in the runtime's MEAF mount but not for hot-loaded editor assets; the editor keeps its own instantiation path for that reason.

The Replication framework calls this on the client to materialize a ghost entity when it receives a Spawn packet referencing a prefab.

Public functions

ReturnsNameDescription
EntityInstantiateInstantiate a previously-loaded PrefabAsset into the scene.
EntityInstantiateByPathPath-based convenience — looks up the prefab through the runtime AssetManager.
boolReapplyPrefabPrefab live-link: rebuild a placed instance from prefab (its source), then replay the instance's stored per-component overrides.
boolReapplyPrefabByPathAs ReapplyPrefab, resolving the source prefab through the runtime AssetManager from the instance root's stored source path.

Function details

Instantiate

C++
static Entity Instantiate(const Ref<PrefabAsset>& prefab, Scene* scene, const Vec3& position = Vec3(0, 0, 0), const Vec3& rotation = Vec3(0, 0, 0))

Instantiate a previously-loaded PrefabAsset into the scene. Returns the root entity (the first prefab entity with parentIndex==-1) or an invalid Entity on failure. position/rotation are applied as a delta to the root entity's transform.

InstantiateByPath

C++
static Entity InstantiateByPath(const std::string& prefabPath, Scene* scene, const Vec3& position = Vec3(0, 0, 0), const Vec3& rotation = Vec3(0, 0, 0))

Path-based convenience — looks up the prefab through the runtime AssetManager. Cheaper for the replication path which only has the string path on the wire.

ReapplyPrefab

C++
static bool ReapplyPrefab(const Ref<PrefabAsset>& prefab, Scene* scene, EntityID rootId)

Prefab live-link: rebuild a placed instance from prefab (its source), then replay the instance's stored per-component overrides. This is the "propagate a prefab edit to instances" path — after the prefab file changes, every instance re-derives its components from the new source while local overrides survive on top. rootId is an instance root (Scene::GetEntityPrefabSource set); the operation walks rootId + descendants that share the same source path and lines each one up with its source entry via Scene::GetEntityPrefabSourceIndex. Entity identity, hierarchy and outside references are preserved (the rebuild is in-place, not a destroy+respawn). Returns false if rootId isn't an instance. Nested-prefab subtrees (a different source path) are left alone — propagate their own prefab separately.

ReapplyPrefabByPath

C++
static bool ReapplyPrefabByPath(Scene* scene, EntityID rootId)

As ReapplyPrefab, resolving the source prefab through the runtime AssetManager from the instance root's stored source path.

Generated from Scene/PrefabInstantiator.h via game.json · Nov 5, 2026Version 1.0.0