Esempio n. 1
0
    void ContextCallBack(object obj)
    {
        switch (obj.ToString())
        {
        case "0":
            NodePopupWindow.InitNodePopup();
            break;

        case "1":
            NodeUtilities.LoadGraph();
            break;

        case "2":
            NodeUtilities.UnloadGraph();
            break;

        case "3":
            NodeUtilities.CreateNode(currentGraph, NodeType.Dialogue, mousePos);
            break;

        case "4":
            NodeUtilities.CreateNode(currentGraph, NodeType.Question, mousePos);
            break;

        case "5":
            NodeUtilities.CreateNode(currentGraph, NodeType.Condicional, mousePos);
            break;

        case "6":
            NodeUtilities.DeleteNode(currentGraph, overNodeID);
            break;

        case "7":
            NodeUtilities.CreateNode(currentGraph, NodeType.Answer, mousePos);
            break;

        case "8":
            NodeUtilities.DisconnectInput(currentGraph, overNodeID);
            break;

        case "9":
            NodeUtilities.DisconnectOutput(currentGraph, overNodeID);
            break;

        case "10":
            NodeUtilities.CreateNode(currentGraph, NodeType.Delay, mousePos);
            break;

        default:
            break;
        }
    }
Esempio n. 2
0
    public override void UpdateView(Rect editorRect, Rect precentageRect, Event e, NodeGraph currentGraph)
    {
        base.UpdateView(editorRect, precentageRect, e, currentGraph);

        GUILayout.BeginHorizontal("box");
        if (GUILayout.Button("Create Graph"))
        {
            NodePopupWindow.InitNodePopup();
        }

        if (GUILayout.Button("Load Graph"))
        {
            NodeUtilities.LoadGraph();
        }


        if (currentGraph != null)
        {
            addNode = EditorGUILayout.Popup(addNode, new string[] { "Add Node", "Add Dialogue", "Add Question", "Add Condition", "Add Answer", "Add Delay" }, "Dropdown");

            switch (addNode)
            {
            case 1:
                NodeUtilities.CreateNode(currentGraph, NodeType.Dialogue, new Vector2(50, 50));
                addNode = 0;
                break;

            case 2:
                NodeUtilities.CreateNode(currentGraph, NodeType.Question, new Vector2(50, 50));
                addNode = 0;
                break;

            case 3:
                NodeUtilities.CreateNode(currentGraph, NodeType.Condicional, new Vector2(50, 50));
                addNode = 0;
                break;

            case 4:
                NodeUtilities.CreateNode(currentGraph, NodeType.Answer, new Vector2(50, 50));
                addNode = 0;
                break;

            case 5:
                NodeUtilities.CreateNode(currentGraph, NodeType.Delay, new Vector2(50, 50));
                addNode = 0;
                break;
            }

            if (currentGraph.selectedNode != null)
            {
                if (currentGraph.selectedNode.nodeType != NodeType.Start && currentGraph.selectedNode.nodeType != NodeType.End)
                {
                    editNode = EditorGUILayout.Popup(editNode, new string[] { "Edit Node", "Disconect input", "Disconect output", "Delete node" }, "Dropdown");
                }
                if (currentGraph.selectedNode.nodeType == NodeType.End)
                {
                    editNode = EditorGUILayout.Popup(editNode, new string[] { "Edit Node", "Disconect input" }, "Dropdown");
                }
                if (currentGraph.selectedNode.nodeType == NodeType.Start)
                {
                    editNode = EditorGUILayout.Popup(editNode, new string[] { "Edit Node", "Disconect output" }, "Dropdown");
                }


                switch (editNode)
                {
                case 1:
                    if (currentGraph.selectedNode.nodeType != NodeType.Start)
                    {
                        NodeUtilities.DisconnectInput(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode));
                    }
                    if (currentGraph.selectedNode.nodeType == NodeType.Start)
                    {
                        NodeUtilities.DisconnectOutput(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode));
                    }
                    editNode = 0;
                    break;

                case 2:
                    NodeUtilities.DisconnectOutput(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode));
                    editNode = 0;
                    break;

                case 3:
                    NodeUtilities.DeleteNode(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode));
                    editNode = 0;
                    break;
                }
            }

            if (GUILayout.Button("Unload Graph"))
            {
                NodeUtilities.UnloadGraph();
            }
        }
        GUILayout.EndHorizontal();
    }