Open sergiyha opened 13 hours ago
Hi @sergiyha,
this query behavior is expected.
A query internally returns the chunks of all matching Archetypes.
The first loop has one the second loop has two matching Archetypes.
The second loop changes the Chunks of _query.Archestypes[1]
.
See: https://github.com/friflo/Friflo.Engine.ECS/blob/main/src/Tests/ECS/Github/Test_GitHub_24.cs#L65
Possible fixes:
Fix 1 https://github.com/friflo/Friflo.Engine.ECS/blob/main/src/Tests/ECS/Github/Test_GitHub_24.cs#L108 This version returns only the matching entities. This list is independent from Archetype changes.
Fix 2 (preferred)
Execute newCB.Playback();
after the loop has finished.
This ensures the Archetypes remain unchanged within the loop.
This is the intended way to use command buffers.
Hi. Please, don't ask me what the hell am I doing with this junk of code) This code represents the execution flow error. Maybe it is not an error and we cannot do things like that but anyway, I am here to show what I've found because it is strange.
The actual problem is that "Debug.LogError(_query.Chunks.Count + " Second Log");" shouldn't be executed twice but it is. Namely, if we do the same thing for a second time. As you can see "Debug.LogError(_query.Chunks.Count + " First Log");" is invoked only once.
FriFlo version: 2.0.0 Environment: Unity Editor 2022.3.47f1