Exemple #1
0
        private void AddNodeCallback(object type, Vector2 mousePosition)
        {
            BehaviourNode node = (BehaviourNode)AddAction((Type)type);

            node.Position = (mousePosition - dragging_Position) - (node.GetDiamentions() * 0.5f);

            Repaint();
        }
Exemple #2
0
        private void DuplicateNode(BehaviourNode original)
        {
            BehaviourNode node = (BehaviourNode)DuplicateAction(original);

            Vector2 diamentions = rightClickedNode.GetDiamentions();

            node.Position += new Vector2(diamentions.x * 0.25f, diamentions.y * 0.5f);

            Repaint();
        }
Exemple #3
0
        private void DrawNodes()
        {
            if (Event.current.type == EventType.MouseMove)
            {
                return;
            }

            if (drawNodeGUI == null)
            {
                drawNodeGUI = new GUI.WindowFunction(DrawNodeWindow);
            }

            Color originalColor = GUI.color;

            BeginWindows();

            for (int i = 0; i < targetGraph.Nodes.Count; i++)
            {
                BehaviourNode node = targetGraph.Nodes[i];

                if (node == null)
                {
                    targetGraph.Nodes.RemoveAt(i);
                    EndWindows();
                    return;
                }

                if (dragging_IsDragging && Event.current.type == EventType.MouseDrag)
                {
                    return;
                }

                Vector2 contentSize = node.GetDiamentions();

                GUI.color = originalColor;
                Rect newRect = GUI.Window(i, new Rect(node.Position.x + dragging_Position.x,
                                                      node.Position.y + dragging_Position.y, contentSize.x,
                                                      contentSize.y + 22), drawNodeGUI, new GUIContent(node.name));

                node.LastRect = newRect;

                node.Position.x = newRect.x - dragging_Position.x;
                node.Position.y = newRect.y - dragging_Position.y;
            }

            GUI.color = originalColor;
            EndWindows();
            GUI.color = originalColor;
        }