> For the complete documentation index, see [llms.txt](https://dots-tutorial.moetsi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dots-tutorial.moetsi.com/unity-ecs/intro-to-unity-ecs.md).

# Intro to Unity ECS

## What you'll develop in this ECS section

![](/files/-MQ3aruTRJpt1D3aRJS3)

Github branch link: <https://github.com/moetsi/Unity-DOTS-Multiplayer-XR-Sample/tree/Building-the-Project/>

{% hint style="info" %}
[Join our Discord for more info](https://discord.com/invite/88j758eUvs)
{% endhint %}

### Functionalities included

* Sub Scenes and conversions
  * Setting components and variables during conversion
* Using EntityManager to make structural changes
* Using command buffers to make structural entity changes
  * Setting up command buffers to run parallel jobs with CreateCommandBuffer().AsParallelWriter()&#x20;
* Adding, setting, and removing components
* Generating authoring components and IConvertGameObjectToEntity interfaces
* Entity queries and .ForEach()
  * Setting local variables for entity queries
  * Scheduling a job with .Schedule()
  * Scheduling a parallel job with .ScheduleParallel()
  * Running on the main thread with .Run()
  * Combining job handles with JobHandle.CombineDependencies()
* Create and destroy entities programmatically
* Create and move entities based on user input
* Create an entity from a prefab
  * Adding cameras to entities
* Hybrid ECS
* New Build Configuration system
  * Creating a base shared configuration
* Sub-second "play" start

## Entity Component System (ECS)

If you can spare **32 minutes** listen to [Far North Entertainment](https://www.youtube.com/watch?v=yTGhg905SCs) explain Unity's ECS and their hybrid approach **(A MUST-WATCH IF HAVE NEVER WORKED WITH ECS)**

If you can spare **64 minutes** listen to Blizzard's [Timothy Ford](https://www.youtube.com/watch?v=W3aieHjyNvw) explain general concepts in ECS (Not Unity-specific ECS, actually Blizzard's own game engine, but the architectural concepts are the same) **<-- ESPECIALLY RECOMMENDED FOR NETCODE**

If you can spare **42 minutes** listen to  Unity's 5-part series overview of ECS: [Part 1](https://www.youtube.com/watch?v=WLfhUKp2gag), [Part 2](https://www.youtube.com/watch?v=z9WE3fwre-k), [Part 3](https://www.youtube.com/watch?v=WZ6-LxwxWEI), [Part 4](https://www.youtube.com/watch?v=j2z5KRWZTDA\&t=1s). [Part 5](https://www.youtube.com/watch?v=D1KShj8ZV_I) for more explanations of ECS

If you can spare **23 minutes** listen to [Code Monkey](https://www.youtube.com/watch?v=ILfUuBLfzGI) explain ECS

If you can spare **9 minutes** listen to [Brackeys](< https://www.youtube.com/watch?v=_U9wRgQyy6s>) (RIP 💀) explain ECS

...and if you can spare **0 minutes** to understand ECS:

![So, yeah... Watch at least one of the videos. Top rec is the first one (Far North Entertainment)](/files/-MPjugO8Yh1_0221_VYq)

### **😃**☯ **Learning Unity ECS will be worth it! Look at these performance gains:**

![Screenshot from the Far North Entertainment video above.](/files/-MXIPDFahCv83nSOlxNH)

### 😳 ☯ Unity ECS will be painful at times (costs of ECS):

Sure, ECS is exciting, but from the Forum threads we linked to above, you can see that there is plenty of complexity that needs to be managed.&#x20;

Learning a functional programming paradigm can be difficult. Shifting out of a OOP mindset dominance can be difficult, too. ECS demands both, to some degree.&#x20;

Luckily, Unity's current ECS architecture is actually a hybrid (of both Monobehaviour and ECS), which eases you into the data-oriented paradigm if you are totally new to it.&#x20;

### Unity resources

{% hint style="info" %}
Read the high-level overview of how Unity thinks about and implements ECS: \
<https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/index.html>
{% endhint %}

{% hint style="info" %}
Read through the explanation of Unity Editor's ECS-specific windows\
<https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/editor-workflows.html>
{% endhint %}

Unity documentation for Unity.Entities 0.50.1-preview\.2:  <https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/>. **Refer to this for more information.**

Unity forums for DOTS: <https://forum.unity.com/forums/data-oriented-technology-stack.147/> . **Pretty responsive to questions.**

Unity samples for ECS: <https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/ReleaseNotes.md> . **More in-depth and complicated examples.**

Big brain discussion on ECS vs. GameObjects: <https://forum.unity.com/threads/whats-your-opinion-on-ecs-video-by-bobby-anguelov.1029871/> . **If you are a bit more hardcore.**

### **To be best prepared for the code-alongs**

* [ ] Watch an ECS explanation video(s)
* [ ] Read through Unity's high-level overview
* [ ] Read through Unity's "Entity Debugger" explanation

{% hint style="info" %}
[Join our Discord for more info](https://discord.com/invite/88j758eUvs)
{% endhint %}
