Working with ECS in Unity
Unity has always been centered around the concept of components; for example, we can add a Movement component to a GameObject so that the object can move. We can also add a Light component to the GameObject to make it emit light. We also add the AudioSource component, which can make the GameObject emit sound. In this case, the GameObject is a container to which game developers can attach different components to provide different behaviors. We can call this architecture a GameObject-Components relationship. In this architecture, we use the traditional OOP programming paradigm to write components, coupling data and behavior together. In the previous section, Object-oriented design pattern versus DOTS, we also discussed the impact of OOP on game performance.
So, to address these issues, Unity introduced ECS, which allows developers to write data-oriented code in Unity. In ECS, data and behavior are separated, which can greatly improve memory usage efficiency...