Switch branches/tags
Nothing to show
Find file Copy path
Cannot retrieve latest commit at this time.
0 contributors

Users who have contributed to this file

24 lines (14 sloc) 1.58 KB


ComponentData in Unity (also known as a Component in standard ECS terms) is a struct that contains only the instance data for an Entity. ComponentData cannot contain methods. To put this in terms of the old Unity system, this is somewhat similar to an old Component class, but one that only contains variables.

Unity ECS provides an interface called IComponentData that you can implement in your code.


Traditional Unity components (including MonoBehaviour) are object-oriented classes which contain data and methods for behavior. IComponentData is a pure ECS-style component, meaning that it defines no behavior, only data. IComponentData is a struct rather than a class, meaning that it is copied by value instead of by reference by default. You will usually need to use the following pattern to modify data:

var transform = group.transform[index]; // Read

transform.heading = playerInput.move; // Modify
transform.position += deltaTime * playerInput.move * settings.playerMoveSpeed;

group.transform[index] = transform; // Write

IComponentData structs may not contain references to managed objects. Since the all ComponentData lives in simple non-garbage-collected tracked chunk memory.

See file: /Packages/com.unity.entities/Unity.Entities/IComponentData.cs.

Back to Unity Data-Oriented reference