Пример #1
0
        private void AddNodeCallback(object type, Vector2 mousePosition)
        {
            BehaviourNode node = (BehaviourNode)AddNode((Type)type);

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

            Repaint();
        }
Пример #2
0
        private void DuplicateNode(BehaviourNode original)
        {
            BehaviourNode node = (BehaviourNode)DuplicateNode((ScriptableObject)original);

            Vector2 diamentions = rightClickedNode.GetDiamentions();

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

            Repaint();
        }
Пример #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.AllNodes.Count; i++)
            {
                BehaviourNode node = targetGraph.AllNodes[i];

                if (node == null)
                {
                    targetGraph.AllNodes.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;
        }