private void LoadAiFromFile(string behaviourPath)
 {
     if (behaviourPath != string.Empty)
     {
         nodes = TreeEditorIO.LoadFileToTree(behaviourPath);
         this.behaviourPath = behaviourPath;
         RecalcWindowNodes();
     }
 }
                private void ContextInsert(object obj)
                {
                    var pos = (Vector2)obj;

                    var nodes = TreeEditorIO.GetNodes(bufferCopy);

                    ShiftWindowPositionNodes(nodes, scrollPos + pos - nodes[0].GetPosition());

                    this.nodes.AddRange(nodes);
                }
                private void SaveFilePanel()
                {
                    var path = EditorUtility.SaveFilePanel(
                        "Save Ai",
                        Application.dataPath + CATALOG,
                        "",
                        "AiBT");

                    behaviourPath = path;
                    TreeEditorIO.SaveTreeToFile(path, nodes);
                }
                private void ContextCopy(object obj)
                {
                    var node = obj as NodeEditor;
                    List <NodeEditor> nodes = new List <NodeEditor> ();

                    nodes.Add(node);
                    GetChildren(node, nodes);
                    Debug.Log("nodes copied " + nodes.Count);

                    bufferCopy = TreeEditorIO.GetJsonData(nodes);
                    Debug.Log(bufferCopy);
                }
                private void HandlePanel()
                {
                    switch (selectedToolbar)
                    {
                    case -1:
                        return;

                    case 0:
                    {
                        if (EditorUtility.DisplayDialog("New Ai", "Are u sure about this?", "Plus", "Minus"))
                        {
                            NewBehaviour();
                            Repaint();
                        }
                    }
                    break;

                    case 1:
                    {
                        var path = EditorUtility.OpenFilePanel(
                            "Open Ai file",
                            Application.dataPath + CATALOG,
                            "AiBT");

                        LoadAiFromFile(path);
                    }
                    break;

                    case 2:
                    {
                        SaveFilePanel();
                    }
                    break;

                    case 3:
                    {
                        ;
                        if (behaviourPath != string.Empty)
                        {
                            TreeEditorIO.SaveTreeToFile(behaviourPath, nodes);
                        }
                        else
                        {
                            SaveFilePanel();
                        }
                    }
                    break;
                    }
                    selectedToolbar = -1;
                }