#Dynamic Buffer in Aspect

1 messages · Page 1 of 1 (latest)

tight isle
#

Does anyone know how to change the element value of Dynamic Buffer in Aspect?

wraith ibex
#
readonly partial struct MyAspect : IAspect {
  readonly DynamicBuffer<Element> m_myElementBuffer;
  
  public void IncrementFirstElementInBuffer(){
    var myElementBuffer = m_myElementBuffer;
    myElementBuffer[0].Value++;
  }
}
tight isle
wraith ibex
#

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;
tight isle
#

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

slim river
#

also you can get element by reference