Esempio n. 1
0
    public int GetTargetNodeIndex(AI_PathfindingNode node)
    {
        for (int i = 0; i < nodes.Length; i++)
        {
            if (node == nodes[i])
            {
                return(i);
            }
        }

        // Debug.Log("Node not found");
        return(-1);
    }
Esempio n. 2
0
    private static void ClearAllNodeConnections()
    {
        // Get all objects in the scene
        List <GameObject> nodeObjs = new List <GameObject>();

        foreach (GameObject GO in Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[])
        {
            nodeObjs.Add(GO);
        }

        // Iterate through all of them and clear the nodes of all connections.
        for (int i = 0; i < nodeObjs.Count; i++)
        {
            AI_PathfindingNode node = nodeObjs[i].GetComponent <AI_PathfindingNode>();
            if (node)
            {
                Undo.RecordObject(node, "Clearing every nodes connections");
                node.connectingNodes.Clear();
            }
        }
    }