Beispiel #1
0
    public IEnumerator GetPathTest(Vector3 entry, Vector3 exit)
    {
        // NavPath = null;
        int   task = ThreadedNavigator.GetPath(entry, exit);
        float time = Time.realtimeSinceStartup;

        while (!ThreadRunner.isComplete(task))
        {
            Debug.Log("Waiting for nav thread to complete...");
            yield return(null);
        }

        List <Vector3> myPath = (List <Vector3>)ThreadRunner.FetchData(task);

        // NavPath = myPath;



        if (myPath == null)
        {
            Debug.Log("No path found.");
        }
        else
        {
            Debug.Log("Path length: " + myPath.Count);

            for (int i = 0; i < myPath.Count - 1; i++)
            {
                Debug.DrawLine(myPath[i], myPath[i + 1], Color.magenta, 5f);
            }
        }
        Debug.Log("Took " + (Time.realtimeSinceStartup - time) + "s to generate.");
    }
    IEnumerator GetPath(Vector3 entry, Vector3 exit)
    {
        NavPath = null;
        int task = ThreadedNavigator.GetPath(entry, exit);

        while (!ThreadRunner.isComplete(task))
        {
            // Debug.Log("Waiting for nav thread to complete...");
            yield return(null);
        }

        List <Vector3> myPath = (List <Vector3>)ThreadRunner.FetchData(task);

        NavPath = myPath;

        if (myPath == null)
        {
            Debug.Log("No path found.");
        }
        else
        {
            Debug.Log("Path length: " + myPath.Count);
        }
    }