I’d like to implement a tick system using a EventHandler (Or System.Action). I already have a tick system implemented using a simple OnTick method defined inside a monobehavior.
Currently I’m not using ticks anywhere. Almost all my jobs are called from OnUpdate().
I’m now looking to subscribe a whole bunch of my systems to this tick event and not use OnUpdate() anymore. The idea is to not create jobs every single frame, but every tick instead, or multiple ticks, while at the same time keeping the jobhandle dependency chain that comes with the OnUpdate() method. I want my jobs to do their work over multiple frames. Therefore if I create a job in SystemA in an OnTick event and SystemB has a job in its own OnTick event that depends on SystemA, how would SystemB know it should execute after A is done? Would a simple ‘UpdateAfter(typeOf(SystemA))’ work? I wouldn’t think so since the OnTick method is just an event that doesn’t and can’t return a JobHandle.
What about the jobs that are still scheduled in OnUpdate() (such as movement/rotation)? I’m pretty sure that those systems will start complaining about dependencies since I’ll be modifying the components/buffers they need in some OnTick methods and the job handle in the OnUpdate method won’t know about them because basically now I have 2 separate job handle chains, assuming I got the tick system working of course.
Here’s the tick system in case it’s needed: