Skip to content
Task guideDevelopmentEngine ccf7d03f

A PrefabAsset stores an authored object graph. Instantiate it into a loaded scene to create a new connected subtree. The instance receives its own persistent object identities; it is not the original prefab’s live graph.

The host must configure prefab instantiation on the SceneWorld with the current serializer and complete asset resolver. That is host composition, not a game-script API. In a loaded scene, this behavior creates one instance from its assigned serialized asset:

using InnoEngine.Scene;
using InnoEngine.Serialization;
public sealed class ObstacleSpawner : GameBehavior
{
[SerializableProperty]
public PrefabAsset? obstacle { get; set; }
protected override void Start()
{
if (obstacle is not null)
gameObject.scene.InstantiatePrefab(obstacle, gameObject.transform);
}
}

The result is the connected root object. The parent must belong to the target scene; unavailable prefab/scene state fails explicitly. The owning world’s Scene and Identity scopes are used even when the caller entered through another temporary presentation scope.

Instantiation is allowed during an execution phase. The new object and components commit together at the phase boundary. Restoration may arrange this new object’s component order before commit, but cannot reorder arbitrary committed objects during execution.

The implementation restores the independent instance before attaching the target parent. Prefab difference mapping includes currently valid pending objects and only calibrates the new subtree’s nested prefabs; it does not require a whole-scene capture while structure is unsettled.

Tag assignments, component/system order and prefab overrides participate in serialization. A copied graph remaps persistent identities and scene-reference aliases. If a type is unavailable, its Missing state retains those mappings so later recovery targets objects in this instance. Follow Missing recovery; replacing an unavailable reference with null would lose that intent.