Example #1
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this);
     }
 }
Example #2
0
        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();
            });
        }