new PrefabManager()
Loads, stores, and manages entity prefab definitions from JSON.
Provides functionality to spawn entities based on these prefabs.
- Source:
Methods
getPrefabDefinition(prefabName) → {PrefabDefinition|undefined}
Gets a prefab definition.
Parameters:
Name | Type | Description |
---|---|---|
prefabName |
string | The name of the prefab. |
- Source:
Returns:
- Type
- PrefabDefinition | undefined
loadPrefabsFromAsset(assetKey) → {boolean}
Loads prefab definitions from a previously loaded JSON asset.
Parameters:
Name | Type | Description |
---|---|---|
assetKey |
string | The key used in AssetLoader for the loaded JSON file containing prefab definitions. |
- Source:
Returns:
True if prefabs were successfully parsed and added, false otherwise.
- Type
- boolean
spawnEntity(prefabName, overrideDataopt)
Spawns an entity based on a prefab definition.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
prefabName |
string | The name of the prefab to spawn. | ||
overrideData |
object |
<optional> |
{} | An object containing data to override the prefab's defaults. Keys are component type names, values are objects with properties to override. Example: { "Position": { "x": 100, "y": 200 }, "Health": { "current": 50 } } |
- Source: