#CommandBufferSystem.Singleton not available in OnCreate?

1 messages · Page 1 of 1 (latest)

keen crown
#

Even when it is set to update after the given command buffer system it can't use it's buffer in OnCreate(). Or does the OnCreate order not follow the Update order?
On start of my system I need the BeginSimulationEntityCommandBufferSystem buffer and I can't get it because the singleton is apparently "null"

ECB = SystemAPI.GetSingleton<EndInitializationEntityCommandBufferSystem.Singleton>().CreateCommandBuffer(state.WorldUnmanaged)

noble fable
#

[CreateAfter(EndInitializationEntityCommandBufferSystem)]

#

on your system

#

that said, using a command buffer system in oncreate is very weird

#

i am questioning what you are trying to do

#

you would always? just use EntityManager to do structural change in oncreate

keen crown
#

Oh, what? Never Seen CreateAfter attributes.

#

On game initialization I create a grid with thousands of Cell entities.

#

So I do it on a job, so I need a buffer.

#

That will probably only make a difference if I have a bunch more initialization in other systems, otherwise having it in a job will probably make no difference.

noble fable
#

you can create your own buffer

#

but i guess you want to avoid the sync

keen crown
#

Yes. I need job.Schedule()

noble fable
#

but it'd probably be a lot faster doing it outside a job tbh

#

if you're creating tha tmany entities

#

using EM.Create batch overloads

keen crown
#

Did seem like it to me because I don't even see a batched way to create a lot of entities with ecb.

noble fable
#

there isn't

#

if you are creating a lot of entities is is magnitudes faster to do it via em