I have this piece of code:
foreach (DynamicBuffer<Items> items in SystemAPI.Query<DynamicBuffer<Items>>())
{
...
}
I am trying to modify a specific element of items
. This is how I am trying to achieve this:
items[3] = modifiedItem;
But I get the error Cannot modify members of 'items' because it is a 'foreach iteration variable'
. How can I modify the elements of items
?