I want to run an ExpensiveWI() over multiple frames, but it keeps blocking and finishing in one frame. the docs say “The “force” parameter will be true if the work item is required to complete immediately.” but I understand what The “force” parameter is.
I am calling like this
AstarPath.active.AddWorkItem(new AstarWorkItem(() => {},
force => {ExpensiveWI(); return true;}
));
How should I call this to get it run over multiple frames on another thread?
You can run work items over multiple frames:
AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
// Called once, right before the
// first call to the method below
},
force => {
// Called every frame until complete.
// Signal that the work item is
// complete by returning true.
// The “force” parameter will
// be true if the work item is
// required to complete immediately.
// In that case this method should
// block and return true when done.
return true;
}));