#Dynamic Buffer in Aspect
1 messages · Page 1 of 1 (latest)
readonly partial struct MyAspect : IAspect {
readonly DynamicBuffer<Element> m_myElementBuffer;
public void IncrementFirstElementInBuffer(){
var myElementBuffer = m_myElementBuffer;
myElementBuffer[0].Value++;
}
}
Are you sure? I think if you do like this, it only modifies the copy of m_myElementBuffer
Yes, copying a DynamicBuffer is fine, it's essentially a ref type.
Tho i did notice the indexer doesn't return a ref, so the bottom line has to be turned into these three:
var element = myElementBuffer[0];
element.Value++;
myElementBuffer[0] = element;
you can not modify by this way, because your Dynamic buffer field must be declared as "readonly"
Oh sorry, I got your idea, it works well. Thanks alot
also you can get element by reference