public override void UpdateView(Rect _editorRect, Rect _percentageRect, Event _e, NodeGraph _nodeGraph)
        {
            base.UpdateView(_editorRect, _percentageRect, _e, _nodeGraph);

            GUILayout.BeginArea(m_viewRect);
            GUILayout.Space(40);
            if (_nodeGraph != null)
            {
                BaseNode node = _nodeGraph.GetSelectedNode();
                if (node != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);

                    EditorGUILayout.LabelField("Name");
                    EditorGUILayout.LabelField(node.GetNodeName());

                    GUILayout.Space(10);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);

                    EditorGUILayout.LabelField("Node Type");
                    EditorGUILayout.LabelField(node.GetNodeType().ToString());

                    GUILayout.Space(10);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);

                    EditorGUILayout.LabelField("Current State");
                    EditorGUILayout.LabelField(node.GetNodeState().ToString());

                    GUILayout.Space(10);
                    GUILayout.EndHorizontal();


                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);

                    node.m_details = (string)EditorGUILayout.TextField(
                        new GUIContent("Details"), node.m_details);

                    GUILayout.Space(10);
                    GUILayout.EndHorizontal();

                    if (node.GetNodeType() == NodeType.ACTION_NODE)
                    {
                        ActionNode actionNode = ((ActionNode)node);

                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);

                        actionNode.m_actionType = (ActionType)EditorGUILayout.EnumPopup(
                            new GUIContent("Action Type"), actionNode.m_actionType);

                        GUILayout.Space(10);
                        GUILayout.EndHorizontal();

                        switch (actionNode.m_actionType)
                        {
                        case ActionType.WALK:
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(10);

                            actionNode.m_moveToPos = (Vector3)EditorGUILayout.Vector3Field(
                                "", actionNode.m_moveToPos, GUILayout.MaxWidth(1000));

                            GUILayout.Space(10);
                            GUILayout.EndHorizontal();
                            break;

                        case ActionType.PICKUPKEY:
                            break;

                        case ActionType.OPENDOOR:
                            break;

                        case ActionType.RESETVARIABLES:
                            break;

                        case ActionType.COUNT:
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            GUILayout.EndArea();
            ProcessEvents(_e);
        }
 public void SetCurrentGraph(NodeGraph _graph)
 {
     m_currGraph = _graph;
 }
示例#3
0
        public virtual void UpdateView(Rect _editorRect, Rect _percentageRect, Event _e, NodeGraph _nodeGraph)
        {
            m_viewRect = new Rect(_editorRect.x * _percentageRect.x,
                                  _editorRect.y * _percentageRect.y,
                                  _editorRect.width * _percentageRect.width,
                                  _editorRect.height * _percentageRect.height);

            m_currGraph = _nodeGraph;

            if (m_currGraph != null)
            {
                m_viewTitle = m_currGraph.GetGraphName();
            }
            else
            {
                m_viewTitle = "No Graph";
            }

            GUI.Box(m_viewRect, m_viewTitle, GetViewSkin().GetStyle("BTNE Node Editor"));
        }
示例#4
0
 public void SetParentGraph(NodeGraph _parentGraph)
 {
     m_parentGraph = _parentGraph;
 }
示例#5
0
        private void ProcessContextMenu(Event _e)
        {
            if (_e.type == EventType.MouseDrag)
            {
                if (_e.button == 0)
                {
                    m_parentGraph.SetSelectedNode(this);
                    BaseNode        selectedNode = m_parentGraph.GetSelectedNode();
                    List <BaseNode> nodes        = new List <BaseNode>();
                    nodes.Add(selectedNode);
                    if (selectedNode.m_outputs.Count > 0)
                    {
                        foreach (NodeOutput output in m_outputs)
                        {
                            if (output == null)
                            {
                                continue;
                            }

                            if (output.m_isOccupied)
                            {
                                BaseNode node = output.m_connectedTo.m_holderNode;

                                if (node != null && node.m_outputs.Count > 0 && node.m_outputs[0] != null)
                                {
                                    foreach (NodeOutput childOutput in node.m_outputs)
                                    {
                                        if (output == null)
                                        {
                                            continue;
                                        }

                                        nodes.Add(childOutput.m_connectedTo.m_holderNode);
                                    }
                                }
                                nodes.Add(output.m_connectedTo.m_holderNode);
                            }
                        }
                    }

                    Vector2 delta = _e.delta;

                    foreach (BaseNode node in nodes)
                    {
                        Rect temp = node.GetNodeRect();
                        temp.x += delta.x;
                        temp.y += delta.y;
                        node.SetNodeRect(temp);
                    }

                    m_parentGraph.isDragging = true;
                }
            }

            if (_e.type == EventType.Layout && _e.button == 1)
            {
                NodeGraph graph = (EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow).GetCurrentGraph();

                if (graph != null)
                {
                    graph.SetIsMakingConnection(false);
                }

                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Delete Node"), false, CallbackOnContextMenu, "0");
                menu.AddItem(new GUIContent("Mark this as Root Node"), false, CallbackOnContextMenu, "1");

                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Add Output"), false, CallbackOnContextMenu, "2");

                menu.ShowAsContext();
            }
        }
示例#6
0
        public override void ProcessEvents(Event _e)
        {
            base.ProcessEvents(_e);

            if (GetViewRect().Contains(_e.mousePosition))
            {
                if (_e.button == 0)
                {
                    if (_e.type == EventType.MouseUp)
                    {
                    }

                    if (_e.type == EventType.MouseDown)
                    {
                        NodeGraph graph = (EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow).GetCurrentGraph();
                        if (graph != null)
                        {
                            graph.SetIsMakingConnection(false);
                        }
                    }

                    if (_e.type == EventType.MouseDrag)
                    {
                    }
                }

                if (_e.button == 1)
                {
                    if (_e.type == EventType.MouseDown)
                    {
                        NodeGraph graph = (EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow).GetCurrentGraph();
                        if (graph != null)
                        {
                            graph.SetIsMakingConnection(false);
                        }

                        m_mousePosition = _e.mousePosition;
                        ProcessContextMenu(_e);
                    }
                }

                if (_e.type == EventType.MouseDrag &&
                    (_e.button == 0 && _e.modifiers == EventModifiers.Alt) ||
                    _e.button == 2)
                {
                    NodeGraph graph = (EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow).GetCurrentGraph();
                    if (graph != null)
                    {
                        graph.SetIsMakingConnection(false);
                    }

                    Vector2 delta = _e.delta;

                    foreach (BaseNode node in m_currGraph.m_nodes)
                    {
                        Rect temp = node.GetNodeRect();
                        temp.x += delta.x;
                        temp.y += delta.y;
                        node.SetNodeRect(temp);
                    }
                }

                if (_e.type == EventType.ScrollWheel)
                {
                    NodeGraph graph = (EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow).GetCurrentGraph();
                    if (graph != null)
                    {
                        graph.SetIsMakingConnection(false);
                    }

                    zoomScale -= _e.delta.x * 0.01f;
                    zoomScale -= _e.delta.y * 0.01f;
                }
            }
        }
示例#7
0
        public override void UpdateView(Rect _editorRect, Rect _percentageRect, Event _e, NodeGraph _nodeGraph)
        {
            base.UpdateView(_editorRect, _percentageRect, _e, _nodeGraph);

            PanningAndZoomUtils.Begin(zoomScale, m_viewRect);

            if (m_currGraph != null)
            {
                m_currGraph.UpdateGraphView(_e, GetViewRect(), GetViewSkin());
            }

            PanningAndZoomUtils.End();

            ProcessEvents(_e);
        }