Exemplo n.º 1
0
    //init defaut values
    void Init()
    {
        isMouseClickOutside     = false;
        isSelecting             = false;
        selectionStartPoint     = Vector2.zero;
        isDraggingSelectedNodes = false;
        isPanning         = false;
        isZooming         = false;
        isDraggingNewLink = false;
        startedLinkAnchor = null;
        selectedNodeCount = 0;

        isMouseClickOnNode   = false;
        isMouseOverNodeFrame = false;
        isDraggingNode       = false;
        mouseOverNode        = null;

        isMouseClickOnLink   = false;
        isMouseOverLinkFrame = false;
        isDraggingLink       = false;
        mouseOverLink        = null;

        isMouseClickOnAnchor   = false;
        isMouseOverAnchorFrame = false;
        mouseOverAnchor        = null;

        isMouseClickOnOrderingGroup   = false;
        isMouseOverOrderingGroupFrame = false;
        isDraggingOrderingGroup       = false;
        isResizingOrderingGroup       = false;
        mouseOverOrderingGroup        = null;
    }
Exemplo n.º 2
0
        public void             RemoveLinkFromAnchors(PWAnchor fromAnchor, PWAnchor toAnchor)
        {
            PWNodeLink link = fromAnchor.links.FirstOrDefault(l => l.toAnchor == toAnchor);

            if (link != null)
            {
                RemoveLink(link);
            }
        }
Exemplo n.º 3
0
    void    PostLinkCreatedCallback(PWNodeLink link)
    {
        // if (link.toNode == null || link.fromNode == null)
        //  return ;

        // Debug.Log("register !");

        // Undo.RecordObject(link.toNode, undoName);
        // Undo.RecordObject(link.fromNode, undoName);
        // Undo.RecordObject(graph, undoName);
    }
Exemplo n.º 4
0
    void    LinkRemovedCallback(PWNodeLink link)
    {
        if (link.toNode == null || link.fromNode == null)
        {
            return;
        }

        //Currently causes weird bugs

        // string undoName = "Link removed";

        // Undo.RecordObject(link.toNode, undoName);
        // Undo.RecordObject(link.fromNode, undoName);
        // Undo.RecordObject(graph, undoName);
    }
Exemplo n.º 5
0
    // string undoName = "Link created";

    void    LinkCreatedCallback(PWNodeLink link)
    {
        if (editorEvents.isDraggingLink || editorEvents.isDraggingNewLink)
        {
            StopDragLink(true);
        }

        //Currently causes weird bugs

        // if (link.toNode == null || link.fromNode == null)
        //  return ;

        // Debug.Log("register !");

        // Undo.RecordObject(graph, undoName);
    }
Exemplo n.º 6
0
        public void             AddLink(PWNodeLink link)
        {
            if (link.fromNode == this)
            {
                link.fromAnchor.AddLink(link);
                OnNodeAnchorLink(link.fromAnchor.fieldName, link.fromAnchor.fieldIndex);
            }
            else if (link.toNode == this)
            {
                link.toAnchor.AddLink(link);
                OnNodeAnchorLink(link.toAnchor.fieldName, link.toAnchor.fieldIndex);
            }
            else
            {
                Debug.LogError("[PWNode] tried to link a node with a link that didn't reference this node");
            }

            UpdateWorkStatus();
        }
Exemplo n.º 7
0
        public void PerlinNoiseToDebugNodeExecution()
        {
            string perlinNodeName = "perlin";
            string debugNodeName  = "debug";
            var    graph          = PWGraphBuilder.NewGraph <PWMainGraph>()
                                    .NewNode <PWNodePerlinNoise2D>(perlinNodeName)
                                    .NewNode <PWNodeDebugInfo>(debugNodeName)
                                    .Link(perlinNodeName, debugNodeName)
                                    .Execute()
                                    .GetGraph();

            PWNodePerlinNoise2D perlinNode = graph.FindNodeByName(perlinNodeName) as PWNodePerlinNoise2D;
            PWNodeDebugInfo     debugNode  = graph.FindNodeByName(debugNodeName) as PWNodeDebugInfo;

            Assert.That(perlinNode != null, "Perlin node not found in the graph (using FindNodeByName)");
            Assert.That(debugNode != null, "Debug node not found in the graph (using FindNodeByName)");

            PWNodeLink link = perlinNode.GetOutputLinks().First();

            Assert.That(link != null, "Link can't be found in the graph");
            Assert.That(link.toNode == debugNode);
        }
Exemplo n.º 8
0
 void LinkCreatedCallback(PWNodeLink link)
 {
     ResetUnlinkableAnchors();
 }
Exemplo n.º 9
0
 public void RemoveLink(PWNodeLink link)
 {
     //call this function will fire an event which trigger the graph and causes anchors to remove link datas.
     // and remove the link
     graphRef.RemoveLink(link);
 }
Exemplo n.º 10
0
    void DrawNodeCurve(PWNodeLink link)
    {
        if (link == null)
        {
            Debug.LogError("[PWGraphEditor] attempt to draw null link !");
            return;
        }
        if (link.fromAnchor == null || link.toAnchor == null)
        {
            Debug.LogError("[PWGraphEditor] null anchors in a the link: " + link);
            return;
        }

        Event e = Event.current;

        link.controlId = GUIUtility.GetControlID(FocusType.Passive);

        Rect start = link.fromAnchor.rectInGraph;
        Rect end   = link.toAnchor.rectInGraph;

        Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
        Vector3 endPos   = new Vector3(end.x, end.y + end.height / 2, 0);

        Vector3 startDir = Vector3.right;
        Vector3 endDir   = Vector3.left;

        float tanPower = (startPos - endPos).magnitude / 2;

        tanPower = Mathf.Clamp(tanPower, 0, 100);

        Vector3 startTan = startPos + startDir * tanPower;
        Vector3 endTan   = endPos + endDir * tanPower;

        if (e.type == EventType.MouseDown && !editorEvents.isMouseOverAnchor)
        {
            if (HandleUtility.nearestControl == link.controlId && e.button == 0)
            {
                GUIUtility.hotControl = link.controlId;

                //unselect all others links:
                UnselectAllLinks();
                UnselectAllNodes();

                link.selected  = true;
                link.highlight = PWLinkHighlight.Selected;
                e.Use();
            }
        }

        //mouse over bezier curve:
        if (HandleUtility.nearestControl == link.controlId)
        {
            editorEvents.mouseOverLink        = link;
            editorEvents.isMouseOverLinkFrame = true;
        }

        if (e.type == EventType.Repaint)
        {
            DrawSelectedBezier(startPos, endPos, startTan, endTan, link.colorSchemeName, 4, link.highlight);

            if (link != null && link.highlight == PWLinkHighlight.DeleteAndReset)
            {
                link.highlight = PWLinkHighlight.None;
            }

            if (link != null && !link.selected && link.highlight == PWLinkHighlight.Selected)
            {
                link.highlight = PWLinkHighlight.None;
            }
        }
        else if (e.type == EventType.Layout)
        {
            float bezierDistance = HandleUtility.DistancePointBezier(e.mousePosition, startPos, endPos, startTan, endTan);
            HandleUtility.AddControl(link.controlId, bezierDistance);
        }
    }