Exemple #1
0
    private IEnumerable <Progress> ScanGraph(NavGraph graph)
    {
        if (AstarPath.OnGraphPreScan != null)
        {
            yield return(new Progress(0f, "Pre processing"));

            AstarPath.OnGraphPreScan(graph);
        }
        yield return(new Progress(0f, ""));

        foreach (Progress progress in graph.ScanInternal())
        {
            yield return(new Progress(Mathf.Lerp(0f, 0.95f, progress.progress), progress.description));
        }
        IEnumerator <Progress> enumerator = null;

        yield return(new Progress(0.95f, "Assigning graph indices"));

        graph.GetNodes(delegate(GraphNode node)
        {
            node.GraphIndex = graph.graphIndex;
        });
        if (AstarPath.OnGraphPostScan != null)
        {
            yield return(new Progress(0.99f, "Post processing"));

            AstarPath.OnGraphPostScan(graph);
        }
        yield break;
        yield break;
    }
Exemple #2
0
        public static void ScanGraph(NavGraph graph)
        {
            if (AstarPath.OnGraphPreScan != null)
            {
                AstarPath.OnGraphPreScan(graph);
            }

            graph.Scan();

            int index = AstarPath.active.astarData.GetGraphIndex(graph);

            if (index < 0)
            {
                throw new System.ArgumentException("Graph is not added to AstarData");
            }

            if (graph.nodes != null)
            {
                for (int j = 0; j < graph.nodes.Length; j++)
                {
                    if (graph.nodes[j] != null)
                    {
                        graph.nodes[j].graphIndex = index;
                    }
                }
            }

            if (AstarPath.OnGraphPostScan != null)
            {
                AstarPath.OnGraphPostScan(graph);
            }

            AstarPath.active.FloodFill();

            AstarPath.active.DataUpdate();
        }