Function AstarPath.LockGraphDataForReading

LockGraphDataForReading ()

Allows you to access read-only graph data in jobs safely.

Public
RWLock.ReadLockAsync LockGraphDataForReading ()

Allows you to access read-only graph data in jobs safely.

You can for example use AstarPath.active.GetNearest(...) in a job.

Using AstarPath.StartPath is always safe to use in jobs even without calling this method.

When a graph update, work item, or graph scan would start, it will first block on the given dependency to ensure no race conditions occur.

If you do not call this method, then a graph update might start in the middle of your job, causing race conditions and all manner of other hard-to-diagnose bugs.

var readLock = AstarPath.active.LockGraphDataForReading();
var handle = new MyJob {
// ...
}.Schedule(readLock.dependency);
readLock.UnlockAfter(handle);