Skip to content

Trecs

A high-performance Entity Component System for Unity, built for deterministic simulation, Burst/Jobs, and recording/playback/rollback.

Trecs

0.x status

Trecs is currently 0.x. The core APIs are stable in spirit but may shift between minor releases ahead of 1.0. Features under Experimental are explicitly in flux — expect breakage there.

Features

  • Cache-friendly storage. Components live in contiguous structure-of-arrays buffers grouped by tag set.
  • Composable building blocks. Aspects bundle component access; sets give sparse subsets without restructuring storage; templates declare entity blueprints with inheritance and partitions.
  • Burst and Jobs out of the box. A source generator emits job structs and chains JobHandle dependencies from the components you read and write — no manual wiring.
  • Deterministic by construction. Fixed-timestep simulation, seeded RNG, isolated input, and built-in snapshot / record / replay with desync detection.
  • Editor tooling. A live entity inspector and a record / scrub / fork timeline window for diagnosing transient bugs.

Quick Start

// 1. Components — unmanaged structs holding per-entity data
public partial struct Position : IEntityComponent { public float3 Value; }
public partial struct Velocity : IEntityComponent { public float3 Value; }

// 2. A tag — an entity category
public struct PlayerTag : ITag { }

// 3. A template — the entity blueprint
public partial class PlayerEntity : ITemplate, ITagged<PlayerTag>
{
    Position Position;
    Velocity Velocity;
}

// 4. A system — logic that runs over matching entities
public partial class MovementSystem : ISystem
{
    [ForEachEntity(typeof(PlayerTag))]
    void Execute(ref Position position, in Velocity velocity)
    {
        position.Value += velocity.Value * World.DeltaTime;
    }
}

// 5. Build and run
var world = new WorldBuilder()
    .AddTemplate(PlayerEntity.Template)
    .AddSystem(new MovementSystem())
    .BuildAndInitialize();

// In a MonoBehaviour:
void Update()     => world.Tick();
void LateUpdate() => world.LateTick();
void OnDestroy()  => world.Dispose();

Inside a system, World is a source-generated property that gives access to the running world for the current phase.

Where to go next

  • Getting Started


    Install Trecs and run your first entity in a Unity scene.

  • Core: World Setup


    Reference for WorldBuilder, lifecycle, and WorldAccessor.

  • Glossary


    The terms — Partition, Set, Tag, Aspect, Accessor — and how they relate.

  • Samples


    A progressive tutorial series plus full sample games.

  • FAQ


    Quick answers to common questions about scope, limits, and design choices.

  • Trecs vs Unity ECS


    Side-by-side comparison if you're sizing up the framework.