top of page
  • Richard Bradley

ECS - Introduction (Part 1)

Updated: Sep 18, 2019

What is the Data-Orientated Tech Stack (DOTS)?


DOTS consists of the following three features.

  • ECS - Allows creation of high performance code by encouraging use of data orientated code to better make use of the CPU cache, therefore reducing Cache Misses and increasing Cache Hits.

  • Burst Compiler - Is based on the LLVM compiler infrastructure, allowing C# jobs to be converted to optimised machine code for the particular abilities of the platform you are compiling on.

  • C# Job System - Provides a safe environment to take advantage of multiple CPU cores whilst also offering fast C# code. The C# Job System offers protection from some of the stumbling blocks of multi-threaded programming such as race conditions.


What are the benefits of this approach?


Performance by default is the main benefit of a DOTS approach to game development, allowing batch processing, multi-threading, optimised memory layouts and performance gains via burst compiled optimised machine code.


What is ECS?


Put simply ECS is a new method of writing game code which adheres to the principle of composition over inheritance.


ECS is an acronym for Entity Component System. Each of these elements work together allowing the programmer to write efficient game code.

  • Entity - An all purpose object, for now think of it as a blank GameObject. Later tutorials in this series will explain why this comparison is incorrect but for now it will suffice.

  • Component - A struct that stores data relating to one particular aspect of an entity. A component is pure data and contains no behaviour code.

  • System - A system receives a collection of entities with a predefined set of components and processes them. In simple terms, system's performs the 'behaviour' of our game.

This forced separation of the game logic and data is one of the biggest boons of ECS and is the pillar of this pattern, allowing efficient memory management and performance gains.


How do I install ECS?


To install ECS you must first open Unity and click on the Package Manager under the Windows menu.


When the Package Manager has opened, make sure that you check the 'Show Preview Packages' so that you can view ECS related packages (ECS is still in preview).


Once you have done the aforementioned you should be able to see an Entities package under the 'All Packages' list. Click the Entities package and install it via the button in the lower right hand corner of the Package Manager.


Depending on the version of Unity you are using, you may find that when installing the Entities package it automatically installs some other related ECS packages, such as the Burst or Mathematics package. Regardless, make sure the following packages are also installed along side the Entities package.


(Further information regarding what these packages do are attached as links in the below headers)





Once you have installed the aforementioned packages, that it. ECS will be installed and ready to use, which is handy, as my following tutorials in this series will require that you have ECS installed to make the most of them.


That's all for this brief introduction into DOTS and ECS, I hope the helped (even a little) to get your head around this new way of coding within Unity.


When you are ready, feel free to peruse the next instalment in this ECS series, linked below.


Until next time.




References

 
179 views0 comments

Recent Posts

See All

ECS - Other Considerations (Part 6)

TODO - Keep popping back here in future to see any updates to ECS or for tips and tricks not included in my individual tutorials.

bottom of page