System/global data

I’m running into some issues trying to refactor global data in the context of having systems and hybrid stuff.

The first one is that I don’t see a way to control startup order of systems. OnCreateManager doesn’t doesn’t follow the system update order. It doesn’t even initialize systems by what group they are in. So systems in simulation can have OnCreateManager called before groups in initialization for example.

Another one is systems get destroyed before Monobehaviour events like OnDisable.

I thought I’d be able to have a system that holds all of the various config data, but that won’t work. I’m pretty much forced to just use a good old singleton.

Using GetOrCreateSystem seems to be how to get the earliest possible hook for loading stuff. But that creates an implied dependency that if it breaks, it wouldn’t be obvious why.

Are there any other hooks I’m missing that are called earlier I could use for loading data?

Edit: Wrong forum,this was supposed to go in the DOTS forum. Will wait for mod to move if possible

ICustomBootstrap Interface ICustomBootstrap | Package Manager UI website

and setup your systems yourself in whatever order you want. I discussed how I use it here: Questions regarding healthy ECS code

Also just in case it wasn’t a typo, don’t use OnCreateManager it’s depreciated, use OnCreate

Another tip is to subclass ComponentSystemGroup and in its OnCreate, instantiate the systems you want to run in the group and do most of your initialization logic there. Override SortSystemUpdateList to do nothing if you want to maintain the order of the systems that you added them in.

1 Like