PrefabLibrary.Instantiate(string, IEntityWorld, Nullable, Nullable, Nullable, string) Method
Definition
Namespace: Brine2D.ECS
Instantiates a registered prefab by name.
public Brine2D.ECS.Entity Instantiate(string name, Brine2D.ECS.IEntityWorld world, System.Nullable<System.Numerics.Vector2> position=null, System.Nullable<float> rotation=null, System.Nullable<System.Numerics.Vector2> scale=null, string? entityName=null);
Parameters
name System.String
The registered prefab name.
world IEntityWorld
The world to create the entity in.
position System.Nullable<System.Numerics.Vector2>
Optional spawn position applied to the root TransformComponent.
rotation System.Nullable<System.Single>
Optional spawn rotation \(in radians\) applied to the root TransformComponent.
scale System.Nullable<System.Numerics.Vector2>
Optional spawn scale applied to the root TransformComponent.
entityName System.String
Optional override for the instantiated entity's name. When null \(default\), the prefab's own name is used. Pass an explicit value when spawning multiple instances so each entity can be found by name.
Returns
Entity
The instantiated entity.
Exceptions
System.Collections.Generic.KeyNotFoundException
Thrown when no prefab with name is registered.