How to Spawn Prefabs in Unity ECS
Unity Entities 0.50
Last Updated on: 6/24/2022

This will take you about 20 minutes in prep time if you don't have Unity set-up, and 30 minutes in coding and debug time.
Stop struggling with the limited documentation. Follow this step-by-step tutorial: "How to Spawn Prefabs in Unity ECS."
Full workflows and code to programmatically spawn prefab entities

This gitbook takes you through step-by-step full workflows and code to programmatically spawn prefab entities. Once you've coded along and fully finished the "How To Spawn Prefabs" tutorial, you will be able to programmatically spawn prefab entities.
High-Level steps to Spawn Prefabs:
Create a prefab and give it an authoring component
Create an empty GameObject that will hold all references to prefabs
Create a spawning system which spawns entities of a given height, width, and depth
FAQ
What is an Entity in Unity ECS?
An entity is a collection of components. Let's say there is an asteroid with a Translation component which is a float3 and denotes the asteroid's position in space. Updating the Entity's Translation component values is not a structural change. The Entity still has the same amount and types of components, just different values.
What is an entity prefab in Unity ECS?
An entity prefab is nothing more than an entity with a Prefab tag and a LinkedEntityGroup. The former identifies the prefab and makes it invisible to all entity queries but the ones who explicitly include prefabs, and the latter links together a set of entities, since entity prefabs can be complex assemblies (equivalent to GameObject hierarchies).
What are system types in Unity ECS?
SystemBase - this is the type of system used most of the time for runtime game play. The systems of this type will do things like provide movement to asteroids or Spawn/Destroy. ComponentSystemGroup - this is groupings of systems. GameObjectConversionSystem - We have interacted with these systems when working with our GameSettingsComponent and our SetGameSettingsSystem. These are used for hybrid development. EntityCommandBufferSystem -EntityCommandBufferSystems are used as "sync" points for structural changes to entities.
Haven’t begun learning Unity DOTS yet, and need to start at the very beginning?
If you haven't yet dipped your toes into learning Unity's new multithreaded Data-Oriented Technology Stack (DOTS), now is the time. You can start at the very beginning with Moetsi’s tutorial, which culminates in your very own deployable sample project. You’ll be guided by full workflows, code-alongs, videos, and GIFs along the way.
Whether you have questions about Unity's multithreaded Data-Oriented Technology Stack (DOTS), or about the RaaS API, or even just general questions about data-intensive pipelines for spatial computing applications, come join our Discord! We maintain a friendly channel, and we're always quick to respond.