#Managed System depend on result of ISystem's jobs

1 messages · Page 1 of 1 (latest)

earnest tiger
#

Hey guys I have SystemBase (CollectibleAttractionSystem2) which depends on a ISystem (CollectibleAttractionSystem1) which runs job. The CollectibleAttractionSystem1 system update collectible attraction to the player and also stuff like timer update in a job. The underlying transform update are made to the gameobject in CollectibleAttractionSystem2. CollectibleAttractionSystem2 also modify the collider layer after time has elapsed.

How do I make CollectibleAttractionSystem2 depend on the completion of CollectibleAttractionSystem1 jobs?

acoustic nacelle
#

systems depend on components

#

if system1 and system2 both want to use the same components they will automatically have the correct dependencies setup

earnest tiger
#

So system2 depends on components being processed by system1. Yes the same component but the order is important

#

How do I enforce that? I heard that jobs don't obey update after rule

acoustic nacelle
#

put
[UpdateAfter(typeof(System1))]
on System2

#

jobs of different dependencies don't obey ordering rules

#

but dependencies will be

#

as in, if you schedule jobA with write dependency on CompX
and jobB with read dependency on CompX

jobB won't run until jobA is done

#

(simplified explanation* it's actually systems that manage dependencies not jobs)

#

but if you ahve jobC that doesn't depend on CompX there's no reasno for JobC to wait before executing is there

#

may as well run it in parallel for speed

earnest tiger
#

I see, so system2 is sure to update after system1 even if system1 schedules parallel jobs? As long as the attribute is placed on top of sys 2?

acoustic nacelle
#

systems always update on main thread

#

and are sequential

#

you can control order with [UpdateBefore|After] where ordering is important

#

the order systems runs is the order jobs are schedule so the order dependencies are setup (again simplified*)

#

so it's order of dependencies will play back, but not necessarily order jobs will end up updating if there's empty thread space and a job that can run, it will run

earnest tiger
#

Yeah but thats what I'm worried about, system1 might not run its jobs on the mainthread right so why would system2 wait for it?

acoustic nacelle
#

if system2 updates after system1

#

system2 will have a dependency on system1 if they use the same components

earnest tiger
#

Ok, what is the Schedule overload taking a dependency as argument for if dependency is managed using that system attribute?

acoustic nacelle
#

that is the system dependency

#

dependencies are controlled by the system

#

getting queries, getting lookups, getting handles etc these all add a dependency to the system

#

when a system update, it goes into the dependency management system, grabs all dependencies that match its component dependencies and combines it into a single handle

#

this is what is passed into OnUpdate

#

you then write your own job handles back to the systems dependency

#

after OnUpdate the system goes into the dependency manage system and now writes its handle back into all the compoonent dependencies so the next system can grab it

earnest tiger
#

Hey thanks a lot for the help. I'll still ask on the unity forums. Still have difficulty understanding. I've had some luck getting some help directly from the devs in the past 😁