Unity Entity Component System Samples
repository·master·Indexed 27 days ago
https://github.com/unity-technologies/entitycomponentsystemsamplesA collection of sample projects and educational materials for Unity's Data-Oriented Technology Stack (DOTS). It covers the Job System, Entities (ECS), Physics, Netcode, and Graphics, featuring tutorials on content management (local and remote catalogs, weak references), fire simulation threading models, bot behavior, and core Entities API concepts such as IJobEntity, IJobChunk, and spatial partitioning.
What's inside entitycomponentsystemsamples
- The Boids sample is a demonstration of advanced Unity Entity Component System (ECS) and Job System techniques. It simulates complex, large-scale flocking behaviors, such as schools of fish moving together and avoiding predators (sharks).
Overview of the Tornado Sample
masterThe Tornado sample is a simulation where a tornado travels in a figure-8 pattern, destroying buildings made of bars connected at their end points. The tornado is represented by a swarm of swirling cubes. The simulation demonstrates high-performance DOTS patterns, including Burst-compiled jobs and unmanaged data structures.Overview of Unity Netcode for Entities
masterUnity Netcode for Entities provides multiplayer features for world synchronization in an Entities-based game. It integrates with the Transport package for socket functionality, Unity Physics for networked physics, and the Logging package for packet dumps.
Key features include:
- Server authoritative synchronization model.
- RPC (Remote Procedure Call) support for control flow and network events.
- Client/server world bootstrapping for clear logic separation and single-process testing (e.g., running a server with multiple clients in the Unity Editor).
- Entity synchronization with default interpolation and client-side prediction.
- Network traffic debugging tools.
- GameObject conversion flow support for hybrid GameObject/MonoBehaviour projects.
Overview of HelloCube Entities API Samples
masterThe HelloCube samples provide simple demonstrations of the core elements of the Unity Entities API. They cover fundamental concepts such as component data, systems, jobs, prefabs, and spatial partitioning.Overview of Mesh Deformation methods in ECS
masterThis sample demonstrates how different mesh deformation methods are implemented using ECS entities:
- BlendShapes (Red meshes): Deformed using blend shape entities.
- Skinning (Blue meshes): Deformed using skin weight entities only.
- Combined (Purple meshes): Uses both blend shapes and skinning on the same mesh.
All values and transforms are animated via an ECS animation system that writes to ECS transform components. The Mesh Deformation system then uses these transforms to calculate the skin matrices.
Overview of the Firefighters Entities Tutorial
masterThe Firefighters tutorial demonstrates a simulation where fire spreads across a field and bots organize into bucket brigade lines to extinguish it. This sample covers core ECS (Entity Component System) concepts including spawning, simulation logic, agent behavior, and UI integration.Overview of DOTS and UI Toolkit Integration Sample
masterThis sample demonstrates how to integrate Unity's UI Toolkit with an Entities-based (DOTS) project. It features a wizard gameplay loop where the player collects ingredients for a magical soup.
Project Structure (
Assets/Scripts):Gameplay/: Contains systems for game state (GameManagerSystem), input (GameInput), movement (PlayerMovementSystem), camera (CameraFollowSystem), quests (QuestSystem), and pickups (EnergyBallSystem).ScriptableObjects/: Contains data definitions for collectables, dialogue, and quests.UI/: Contains UI Toolkit wrappers (UIScreenand its derivatives) and UI-specific logic.
Explore Entities Graphics HDRP Feature Samples
masterThe Entities Graphics HDRP Samples Project provides feature sample Scenes demonstrating various capabilities of HDRP when used with Entities Graphics. Most sample scenes are located in the
_SampleScenes_folder and utilize GameObjects within a SubScene.Because these GameObjects are in a SubScene, Unity renders them using Entities Graphics in Edit Mode, Play Mode, and in the built player. Use these scenes to understand how to implement lighting, material overrides, and runtime entity manipulation within an HDRP environment.
Understand Baking and Entity Scenes
masterBaking is a build-time process that converts sub scenes (Unity scene assets embedded via a
SubSceneMonoBehaviour) into entity scenes (serialized entities and components for runtime loading).Key components of the baking process:
- Baker: A class extending
Baker<T>(whereTis a MonoBehaviour). The MonoBehaviour is called an authoring component. - Baking System: A system marked with the
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]attribute. These systems can modify baked entities but should not access original GameObjects.
Baking Workflow:
- A corresponding entity is created for each GameObject in the sub scene.
- Bakers for each authoring component execute, reading authoring data and adding components to the entity.
- Baking systems execute to further modify entities (add/remove components, create/destroy entities).
Incremental Baking: When a sub scene is modified, only bakers reading the modified components are re-executed, but baking systems always re-execute in full.
- Baker: A class extending
Explore Entities Graphics URP Feature Samples
masterThe Entities Graphics URP Samples project provides various scenes demonstrating specific features of the Universal Render Pipeline (URP) when used with Entities Graphics. Most sample scenes are located in the
_SampleScenes_folder and are organized by topic.Note that many of these scenes use GameObjects within a
SubScene. Because these GameObjects exist in a SubScene, Unity renders them using Entities Graphics in Edit Mode, Play Mode, and in the built player.Understand Mesh Deformation methods in ECS
masterThis sample demonstrates how different deformation methods are applied to entities using ECS components:
- BlendShapes (Red meshes): Deformed using blend shape entities.
- Skinning (Blue meshes): Deformed using skin weight entities only.
- Combined (Purple meshes): Both blend shapes and skinning applied to the same mesh.
All values and transforms are animated via an animation system that writes to ECS transform components. The Mesh Deformation system then uses these transforms to calculate the skin matrices.
Explore LODs in Entities Graphics
masterThis sample scene demonstrates how Level of Detail (LOD) works within the Entities Graphics system. The scene features a grid of cubes where each LOD level is assigned a unique color to make transitions visible.