Unity Entity Component System Samples

repository·master·Indexed 27 days ago

https://github.com/unity-technologies/entitycomponentsystemsamples

A 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.

Tokens
44.8K
Snippets
27
Records
309
Agent score
92%

What's inside entitycomponentsystemsamples

  1. Overview of Unity Netcode for Entities

    master

    Unity 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.
  2. Overview of Mesh Deformation methods in ECS

    master

    This 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.

  3. Overview of DOTS and UI Toolkit Integration Sample

    master

    This 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 (UIScreen and its derivatives) and UI-specific logic.
  4. Explore Entities Graphics HDRP Feature Samples

    master

    The 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.

  5. Understand Baking and Entity Scenes

    master

    Baking is a build-time process that converts sub scenes (Unity scene assets embedded via a SubScene MonoBehaviour) into entity scenes (serialized entities and components for runtime loading).

    Key components of the baking process:

    • Baker: A class extending Baker<T> (where T is 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:

    1. A corresponding entity is created for each GameObject in the sub scene.
    2. Bakers for each authoring component execute, reading authoring data and adding components to the entity.
    3. 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.

  6. Explore Entities Graphics URP Feature Samples

    master

    The 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.

  7. Understand Mesh Deformation methods in ECS

    master

    This 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.