Skip to content

Commit

Permalink
Tests - update EnumerateQueryChunks() example
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Aug 2, 2024
1 parent 35f3257 commit a634475
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Tests/ECS/Examples/Optimization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public static void EnumerateQueryChunks()
foreach (var (components, entities) in query.Chunks)
{
for (int n = 0; n < entities.Length; n++) {
Console.WriteLine($"MyComponent.value: {components[n].value}");
// > MyComponent.value: 42
// > MyComponent.value: 43
// > MyComponent.value: 44
Console.WriteLine(components[n].value); // > 42 44 44
}
}
// Caution! This alternative to iterate components is much slower
foreach (var entity in query.Entities) {
Console.WriteLine(entity.GetComponent<MyComponent>().value); // > 42 44 44
}
}

[Test]
Expand Down

0 comments on commit a634475

Please sign in to comment.