public sealed class PrefabAn entity subtree, captured once and stamped out many times.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Held as a world of its own — the template — rather than as a pile of blobs. That gives the capture nothing to serialise and nothing to reinterpret: the components are already laid out exactly as they will be in the target, so instantiating is a run of CreateMany calls, one per distinct archetype, and a row copy each. [04](../../../docs/plan/04-ecs-and-scripting.md) asks for "one archetype write per archetype, not entity-at-a-time"; this is that, and it also means a prefab can be inspected and edited with the same API as anything else.
The hierarchy is rebuilt, not remapped. Parent, Child and Sibling hold entity handles, and a handle copied into another world names a slot in the world it came from. Rather than translate them — which would need to know which fields of which components are handles — the capture records the tree as indices and the instantiation re-parents. Any *other* component holding an Entity comes across verbatim and is a bug in the prefab, which is why doc 04 says never to store one.
Fields and properties (3)
public string NameA name, for diagnostics and for the asset that will own it.
public int EntityCountHow many entities one instance creates.
public int ArchetypeCountHow many distinct archetypes it touches — how many bulk creates an instantiation is.
Methods (7)
public bool NodeHas<T>(int node)Whether one of the captured nodes carries a component.
public static Prefab CaptureFrom(World world, Entity root, string name = "Prefab")Captures an entity and everything below it.
public Entity Instantiate(World world, LocalTransform? at = null)Stamps out an instance.
public Entity Instantiate(World world, Span<Entity> created, LocalTransform? at = null)Stamps out an instance and says which entity each of its nodes became.
public Entity InstantiateOnto(World world, Entity standIn, Span<Entity> created, LocalTransform? at = null)Stamps out an instance over an entity that was already standing in for its root.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override string ToString()Renders the name and what an instance costs.
Used by (10)
- NetworkPrefabVixen.Net.Engine
- NetworkPrefabRegistryVixen.Net.Engine
- NetworkSpawnSystemVixen.Net.Engine
- NetworkSpawnTestsVixen.Net.Engine.Tests
- NetworkSpawnerVixen.Net.Engine
- PlayerSpawnerTestsVixen.Net.Engine.Tests
- PrefabAssetVixen.Engine
- SceneAndPrefabTestsVixen.Engine.Tests
- SceneAssetTestsVixen.Engine.Tests
- SceneImporterTestsVixen.Editor.Assets.Tests