private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); } }
private static void TryProcessNext() { if (isProcessing || pathRequests.Count == 0) { return; } isProcessing = true; var request = pathRequests.Dequeue(); var path = PathFinder.instance.FindPath(request.start, request.end, request.preferBreakWalls); request.callBack(path); // Do max one path finding per frame FrameSyncUtility.SyncUpdate(() => { isProcessing = false; TryProcessNext(); }); }