public void LaunchAI()
 {
     //create test AI nodes
     aiBlock = new AIBlock ();
     //		TestNodeAI ();
     //		InputTestNodeAI ();
     NestedListInputTestNodeAI ();
     //		SettingTargetTestNodeAI ();
     //visualize test Ai for current purposes
     VisualScriptEditor.inst.ShowAI (aiBlock);
     //Launch them
     StartCoroutine (AICoroutine());
 }
    public void ShowAI(AIBlock _aiBlock)
    {
        aiBlock = _aiBlock;

        xOffset = -600.0f;
        yOffset = 350.0f;
        processedNodes = new List<BaseNode> ();
        nodeVisuals = new List<VisualContainer> ();
        for (int i = 0; i < aiBlock.coreNodes.Count; i++) {
            yOffset = 350.0f;

            processedNodes.Add(aiBlock.coreNodes[i]);
            GameObject visualContainer = Instantiate(containerPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            visualContainer.transform.SetParent(editorField);
            visualContainer.transform.localScale = Vector3.one;
            //connect to node
            VisualContainer container = visualContainer.GetComponent<VisualContainer>();
            nodeVisuals.Add (container);
            nodeVisualsDict.Add(aiBlock.coreNodes[i], container);
            container.node = aiBlock.coreNodes[i];
            container.title.text = container.node.GetType().ToString();
            //

            if(aiBlock.coreVisuals.Count > i){

            }
            else{
                visualContainer.transform.localPosition = new Vector3 (xOffset + xStep/2, yOffset + yStep/2, 0);
                xOffset += xStep;
                yOffset -= yStep;
            }

            if (aiBlock.coreNodes[i].lowerNodes != null){
                if (aiBlock.coreVisuals.Count > i && aiBlock.coreVisuals[i].lowerVisualData != null){
                    ShowNextTier(aiBlock.coreNodes[i].lowerNodes, aiBlock.coreVisuals[i].lowerVisualData);
                }
                else{
                    ShowNextTier(aiBlock.coreNodes[i].lowerNodes, null);
                }
            }

        }

        // spawning blocks of additional data blocks that are not part of hierarchy
        for (int i = 0; i < aiBlock.dataNodes.Count; i++) {
            yOffset = -350.0f;

            processedNodes.Add(aiBlock.dataNodes[i]);
            GameObject visualContainer = Instantiate(containerPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            visualContainer.transform.SetParent(editorField);
            visualContainer.transform.localScale = Vector3.one;
            //connect to node
            VisualContainer container = visualContainer.GetComponent<VisualContainer>();
            nodeVisuals.Add (container);
            container.node = aiBlock.dataNodes[i];
            container.title.text = container.node.GetType().ToString();
            //
            if(aiBlock.dataNodesVisuals.Count > i){

            }
            else{
                visualContainer.transform.localPosition = new Vector3 (xOffset + xStep/2, yOffset + yStep/2, 0);
                xOffset += xStep;
                yOffset -= yStep;
            }
            if (aiBlock.dataNodes[i].lowerNodes != null){
                if (aiBlock.dataNodesVisuals.Count > i && aiBlock.dataNodesVisuals[i].lowerVisualData != null){
                    ShowNextTier(aiBlock.dataNodes[i].lowerNodes, aiBlock.dataNodesVisuals[i].lowerVisualData);
                }
                else{
                    ShowNextTier(aiBlock.dataNodes[i].lowerNodes, null);
                }
            }
        }

        // show elemnts and connections
        for (int i = 0; i < nodeVisuals.Count; i++) {
            ShowNodeElements(nodeVisuals[i]);
        }
        for (int i = 0; i < nodeVisuals.Count; i++) {
            ShowElementsConnections(nodeVisuals[i]);
        }
    }