Prefab Scripting API

Module:

engine.resources.prefab_resource

Handle Type:

PrefabId

Functions

request_prefab(path: string): PrefabId

Request a prefab resource from the provided path and returns the corresponding resource ID. This resource request is synchronous.

Arguments:
  • path : string - the path to the prefab file

Returns:
  • PrefabId - the resource ID of the prefab resource

instantiate_prefab(prefabId: PrefabId; data: NodeData = NodeData()): NodeId

Instantiates a prefab resource. data holds creation parameters that will override corresponding fields in prefab root If a field is not initialized, a value set in prefab will be used

Arguments:
  • prefabId : PrefabId - the id of the prefab resource

  • data : NodeData - parameters for prefab instantiation

Returns:
  • NodeId - the root node of the instantiated prefab.

Usage example:

let node = instantiate_prefab(prefabId, NodeData(
    position = float3(10, 0, 0),
    parent = parentNode
))