public void Execute(Entity entity, int index, ref Instance tester) { tester.f = 10 * dt; DynamicBuffer <SomeBufferElement> someDynamicBuffer = someBufferElement [entity]; SomeBufferElement buffer = someDynamicBuffer [0]; // Uncomment as needed // buffer.i = 99 ; // someDynamicBuffer [0] = buffer ; // Debug Will throw errors in Job system // Debug.Log ( "#" + index + "; " + someDynamicBuffer [0].i + "; " + someDynamicBuffer [1].i ) ; }
// protected override void OnCreateManager ( int capacity ) // Obsolete protected override void OnCreate( ) { base.OnCreate( ); Debug.LogWarning("Burst is disabled, to use Debug.Log in jobs."); Debug.LogWarning("Jobs are executed approx every second."); Instance instance = new Instance(); Entity entity = EntityManager.CreateEntity(typeof(Instance)); EntityManager.SetComponentData(entity, instance); EntityManager.AddBuffer <SomeBufferElement> (entity); DynamicBuffer <SomeBufferElement> someBuffer = EntityManager.GetBuffer <SomeBufferElement> (entity); // Add two elements to dynamic buffer. SomeBufferElement someBufferElement = new SomeBufferElement(); someBufferElement.i = 100000; someBuffer.Add(someBufferElement); someBufferElement.i = 200000; someBuffer.Add(someBufferElement); EntityManager.Instantiate(entity); // Clone entity. entity = EntityManager.CreateEntity(typeof(Instance)); EntityManager.SetComponentData(entity, instance); EntityManager.AddBuffer <SomeFromEntityBufferElement> (entity); DynamicBuffer <SomeFromEntityBufferElement> someFromEntityBuffer = EntityManager.GetBuffer <SomeFromEntityBufferElement> (entity); // Add two elements to dynamic buffer. SomeFromEntityBufferElement someFromEntityBufferElement = new SomeFromEntityBufferElement(); someFromEntityBufferElement.i = 1000; someFromEntityBuffer.Add(someFromEntityBufferElement); someFromEntityBufferElement.i = 10; someFromEntityBuffer.Add(someFromEntityBufferElement); EntityManager.Instantiate(entity); // Clone entity. }
// protected override void OnCreateManager ( ) // for Entities 0.0.12 preview 20 protected override void OnCreateManager(int capacity) { base.OnCreateManager(capacity); Instance instance = new Instance(); Entity entity = EntityManager.CreateEntity(typeof(Instance)); EntityManager.SetComponentData(entity, instance); EntityManager.AddBuffer <SomeBufferElement> (entity); var bufferFromEntity = EntityManager.GetBufferFromEntity <SomeBufferElement> (); var buffer = bufferFromEntity [entity]; SomeBufferElement someBufferElement = new SomeBufferElement(); someBufferElement.i = 6; buffer.Add(someBufferElement); someBufferElement.i = 7; buffer.Add(someBufferElement); }